问题
I'm working on a .NET Core solution. For one of the projects within the solution, I need to build a Nuget package.
Project A has a reference to another project B in the solution, set up as a project reference. Project B has a dependency on a Nuget package C.
Now, when I create a Nuget package for A, it includes A.dll and B.dll but not C.dll
Can someone help me figure this out? How can I include all 3 .dlls?
Thanks, Andy
回答1:
See https://github.com/NuGet/Home/issues/3891 for the feature request for dotnet.exe pack
to the nuget client team. There are workarounds and debates in that issue.
Thx, Rob Relyea, NuGet Client Team
回答2:
You can certainly solve this by creating your own nuspec file. I am not sure how to do it within the context of the csproj file.
For example, with #csla we manage all our own nuspec files because there are so many moving parts.
Within a nuspec file you can list the specific files you want included, along with any package dependencies. So in your example it sounds like your nuspec would include the project A and B assemblies, so something like this:
<files>
<file src="..\..\bin\Release\netstandard\netstandard2.1\**\A.dll" target="lib\netstandard2.1" />
<file src="..\..\bin\Release\netstandard\netstandard2.1\**\B.dll" target="lib\netstandard2.1" />
</files>
And would declare the dependency to package C.
<dependencies>
<group targetFramework="netstandard2.1">
<dependency id="C" version="1.0.0" />
</group>
</dependencies>
You can see numerous examples in the #csla repo. Perhaps the closest (not using wildcards) is the Csla.Blazor.nuspec file.
来源:https://stackoverflow.com/questions/61668289/how-to-create-nuget-package-with-nested-dependencies