0

I apologize for the vague title, but I am not sure how to phrase it.

I am working with a "custom" appsettings.json folder. The json file lives in the class library that is using it. I want to create a nuget package to install this class library but also make sure that appsettings.json is copied into the correct directory (if I am installing it in a console app, the build output directory).

I have seen one "answer"

How can I set the 'copy to output directory' property in my nuspec file?

but I am using VS 2019 and .NET Standard 2.0. I am pretty frustrated so any help (even if told not possible) is appreciated! Thanks in advance.

Mr Qian
  • 21,064
  • 1
  • 31
  • 41
Michael
  • 17
  • 3

1 Answers1

2

If you just want to install this nuget package only on net core projects, you could just add these node under the net standard project's csproj file:

<ItemGroup>
        <None Update="xxx\appsettings.json" Pack="true" PackagePath="contentFiles\any\any;content">
            <PackageCopyToOutput>true</PackageCopyToOutput>
        </None>
</ItemGroup>

Then, repack the net standard project into a nuget package, before install it under a new project, you should clean nuget caches first.

If you want to install this nuget package into a net framework project, you should try to use <package_id>.props file on the net standard2.0 lib project.

Please try the function under this link.

Mr Qian
  • 21,064
  • 1
  • 31
  • 41