1

I am trying to create a .NET Standard 2.0 NuGet package that standardizes how I consume NLog across .NET Framework and .NET Core applications. I have an nlog.config file that is the standard boilerplate layout for all the apps I will be writing. I also have a couple of classes that basically wrap NLog, and standardize how I interact with the library.

I want my NuGet package to deploy this standard nlog.config xml file to the project consuming my package, and set the Copy To Output Directory value to either Copy Always or Preserve Newest. I know it has something to do with the .nuspec file, and build folders, and .props/.targets files, but I am completely lost now after trying numerous posts like these:

Set content files to "copy local : always" in a nuget package

How to add files to build folder in csproj NuGet package without .nuspec

Setting file properties with NuGet using .targets file

I don't know who to believe. It seems there are several ways to go about it, but none of them have worked. Is it an issue with .NET Standard? Am I just doing something wrong?

My .csproj file sections of interest:

<ItemGroup>
    <None Include="build\*.*" Pack="true" PackagePath="build">
        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
</ItemGroup>

<ItemGroup>
    <Content Include="nlog.config" Pack="true" CopyToOutputDirectory="PreserveNewest">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
</ItemGroup>

0 Answers0