I've been looking for any way to set the CopyToOutput attribute to true for content files I'm including in a NuGet package built in VS2017 from a .NET Standard Library project.
When adding the files using the Content node, I can see the files in the package, but when looking at the nuspec that is pulled out when it's cached locally, there is no CopyToOutput, so it's false by default. In this case, when it's referenced in an ASP.NET Core site, nothing is copied into the application. If I manually update that cached version to include the attribute and set it to true and restore, everything gets copied.
Unfortunately, I looked into the Nuget.Build.Tasks.Pack.dll and it looks like there's no way to pass that value through an MSBuild property.
Did anybody run into this issue and has a workaround?
nuspec file is not required to create packages for SDK-style projects (typically . NET Core and . NET Standard projects that use the SDK attribute).
on the toolbar of the Assembly Explorer window or choose File | Open from NuGet Packages Cache in the main menu . This will open the Open from NuGet Packages Cache dialog. The dialog lists packages from all NuGet cache locations on your machine. Use the search field in the dialog to find the desired package.
See this pull request: Allow specifying copyToOutput and flatten as Metadata on Content items when packing sdk csproj #1450
You'll need to set PackageCopyToOutput to true in the source csproj for the content.
<Content Include="...">
<PackageCopyToOutput>true</PackageCopyToOutput>
</Content>
and once build the package, it will include CopyToOutput="true" for that content.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With