Reputation: 2724
Is it possible for dotnet publish
to copy contentFiles
to output from a transitive package dependencies?
In this scenario, I have three projects:
nuspec
containing:<contentFiles>
<files include="any/any/someContent.txt" buildAction="None" copyToOutput="true" flatten="false"/>
</contentFiles>
PackageReference
to Content nugetPackageReference
to Lib nugetThe Lib project shows the contentFiles in the project explorer and copies to output on build, but the ConsoleApp project does neither.
I need dotnet publish ConsoleApp.csproj
to include someContent.txt
from the Content nuget in the publish output.
Somewhat related posts for context:
Upvotes: 5
Views: 1518
Reputation: 1095
contentFiles
are Private Assets by default. You need to change the PrivateAssets
metadata in the reference from Lib
to Content
, so that it doesn't include contentFiles
, like this:
<ProjectReference Include="...">
<PrivateAssets>analyzers;build</PrivateAssets>
</ProjectReference>
More information here: https://learn.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#controlling-dependency-assets
Upvotes: 7