Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
ContentFiles to output directory in project which refers a nuget which refers another nuget package #9297
I'm building multiple nuget packages which include content files and can refer each other. These content files should always be copied to output directory.
The problem i'm having is that content files from a nuget package are correctly outputted to the output directory if the project references the nuget directly. But if a nuget package refers another nuget package with contentfiles, these content files will not copy to the output directory and are located in the wrong path.
Does anyone know a solution to this problem?
I've added an example to the repo here: https://github.com/Bramvanelderen10/nugetdemoi
So lets say i have the following 2 packages
In both projects csproj files i have defined the following entries for the content files
Now i package both the base package and the utilities package using
As you can immidiatly see in the nuspec the element for contentFileBase.json is invalid. It is missing both the
Used dotnet cli dotnet pack command. With dotnet core 2.2.4
By default, all assets are Private assets. You would need to remove
Add this to your Package Reference
By the way...did you already see this doc and does it make sense? If it's not clear, I'll make sure we have an issue to improve this section of Docs. Thanks for any feedback!
@donnie-msft That worked! I read the documentation, where i went wrong was the IncludeAssets element, i thought if i add that with the all value that it would include all files from the package.
I do still have a small problem. Now i do see the file in the resources folder where i expect, but there is a copy still in the root directory. Can this be removed somehow? I've updated the demo project:
Thank you very much
One last question, I tried removing that element but it did not work. I've also tried playing around with different configurations in PrivateAssets, IncludeAssets and ExcludeAssets but all of that did not work.
The only thing that seems to work now is after i use dotnet pack and go to the generated package and edit the nuspec in there. Where i set the buildAction to none manually like:
But if i set the buildAction to none in visual studio it will change the csproj element to a None element which is not included as contentFile.