How to create Nuget package with nested dependencies

蓝咒 提交于 2021-01-29 15:43:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!