Reputation: 13846
My .netstandard2.0 package packs a config file within the nuget package, it was packed with this directive:
<ItemGroup>
<None Include="apps.config" Pack="True" PackagePath="lib/$(TargetFramework)">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Using the nuget package explorer, i can see that the file is indeed packed in the nuget package, put under the same directory as the .dll file.
Then I added this package into another project using the install-package command, but when run the app, only the .dll file is copied into bin\debug, not the config file. How can I copy the config file as well when doing a restore?
Upvotes: 0
Views: 678
Reputation: 100761
Use NuGet's contentFiles
feature to include content to be consumed by the project. If you package the file as Content
item instead of None
and add the PackageCopyToOutput="true"
metadata, NuGet will create the right paths and nuspec content:
<ItemGroup>
<None Remove="apps.config" />
<Content Include="apps.config" Pack="true" PackageCopyToOutput="true" />
</ItemGroup>
Upvotes: 1