Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

How to transitively copy files to output across NuGet packages?

$
0
0

I have a PackageA that needs a file to be copied to the output of the final application to work as expected.I include the needed file into my PackageA's project with these lines:

<ItemGroup><Content Include="test.txt"><PackageCopyToOutput>true</PackageCopyToOutput></Content></ItemGroup>

If I consume the generated package directly, the file test.txt is copied to the output.

Now, if I reference this PackageA from another PackageB, and reference only the PackageB rather than PackageA, the file test.txt is not copied at all to the output while I expected this file to be transitively copied.

I tried digging into the issues of the NuGet/Home repository and found that we should play with the PrivateAssets or something like that (Issue on github and all its siblings). But I never succeeded in making this work.

I made a github repository to show off the issue I'm facing.

I also know that it is possible to copy the file by including .props or a .targets file doing so with a pre-build or post-build action, but I find this solution quite hacky, not elegant, and hard to set up and maintain over time. Moreover, I do have the feeling that NuGet is supposed to support this kind of usage quite easily, so maybe I have missed something somewhere.

On StackOverflow, there are also many posts about transitive copy. However, as far as I dig, it always talks about packages that are directly consumed by a project, or a tree of projects. My issue is a package referenced by another package itself referenced by a project.


Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>