After installing NLog and NLog.config using NuGet package manager I am unable to edit NLog.config, it shows lock icon on it. How to unlock it?


After installing NLog and NLog.config using NuGet package manager I am unable to edit NLog.config, it shows lock icon on it. How to unlock it?


For newer projects the NLog.Config package is not recommended.
From: https://www.nuget.org/packages/NLog.config
Note: Unfortunately this package won't work well when using
<PackageReference>Advised to:
- download manually: https://raw.githubusercontent.com/NLog/NLog/dev/src/NuGet/NLog.Config/content/NLog.config
- set "Copy To Output Directory" to "Copy if newer"
I had the same problem - the NuGet package for Nlog config was installed in a different location than the root project directory, like for example C:\Users\User\.nuget\packages\nlog.config\4.7.7\contentFiles\any\any\NLog.config instead of I:\workspaceVS\net50\ConsoleCoreApp1.
I managed to solved the problem by copying manually the file Nlog.config into the project's root directory and then reference it in my .csproj file in the following way :
<Project Sdk="Microsoft.NET.Sdk">
...
<ItemGroup>
<None Update="NLog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="NLog.xsd">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
...
<ItemGroup>
</Project>
instead of :
<Project Sdk="Microsoft.NET.Sdk">
...
<ItemGroup>
<None Update="C:\Users\User\.nuget\packages\nlog.config\4.7.7\contentFiles\any\any\NLog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="C:\Users\User\.nuget\packages\nlog.schema\4.7.7\contentFiles\any\any\NLog.xsd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
...
<ItemGroup>
</Project>
And now, when I release it, it shows directly in the output directory :
.(I:\workspaceVS\net50\ConsoleCoreApp1\bin\Release\net5.0\win-x86)
├── ...
└── Nlog.config # Holds the configuration for Nlog
You can find the NLog.config file in {Project Folder}\bin\Debug\net5.0\. You can open and edit it as you like with Notepad or Visual Studio.