将依赖程序集复制到 nuget 包中
Copy dependency assemblies into nuget package
我得到了一个包含许多 .Net Standard 2.0 项目的 VS 2019 解决方案。
我的主项目对另一个项目具有项目依赖性,而另一个项目对 Dapper 程序集具有依赖性。
将主工程编译成NuGet包后,该包还没有Dapper依赖。
如何将 Dapper 程序集包含到 NuGet 包中?
Copy dependency assemblies into nuget package
打包主项目时,它会将 another project
作为 nuget 包,因为 main project
引用 another project
。您应该注意到 dotnet pack
会将 another project
视为一个 nuget 包,但您没有另外打包 another project
。
所以 它会在包源上丢失 another project
并且依赖项 Dapper 存在于 another project
下。
不在主工程的依赖中,在另一个工程的依赖包中
建议
============================================= =============
1)这个你不用太担心。您还应该 pack another project
作为 nuget 包,然后将其放入 nuget package source.
像这样:
虽然依赖Dapper没有显示在主工程上,但显示在依赖包下。并且和依赖项目一起安装到项目中。
============================================= ========
请注意:
在安装任何版本的包之前,您应该先clean nuget caches first或删除C:\Users\xxx(current user)\.nuget
下的缓存包文件夹
============================================= ============
2)如果你还想在主工程下看到依赖Dapper,你也应该安装 Dapper nuget包进入主工程
然后打包就可以看到依赖Dapper在里面
============================================= ============
另外,如果你不希望引用的项目成为依赖nuget包,而只是一个程序集dll,你可以参考.
我得到了一个包含许多 .Net Standard 2.0 项目的 VS 2019 解决方案。 我的主项目对另一个项目具有项目依赖性,而另一个项目对 Dapper 程序集具有依赖性。 将主工程编译成NuGet包后,该包还没有Dapper依赖。 如何将 Dapper 程序集包含到 NuGet 包中?
Copy dependency assemblies into nuget package
打包主项目时,它会将 another project
作为 nuget 包,因为 main project
引用 another project
。您应该注意到 dotnet pack
会将 another project
视为一个 nuget 包,但您没有另外打包 another project
。
所以 它会在包源上丢失 another project
并且依赖项 Dapper 存在于 another project
下。
不在主工程的依赖中,在另一个工程的依赖包中
建议
============================================= =============
1)这个你不用太担心。您还应该 pack another project
作为 nuget 包,然后将其放入 nuget package source.
像这样:
虽然依赖Dapper没有显示在主工程上,但显示在依赖包下。并且和依赖项目一起安装到项目中。
============================================= ========
请注意:
在安装任何版本的包之前,您应该先clean nuget caches first或删除C:\Users\xxx(current user)\.nuget
============================================= ============
2)如果你还想在主工程下看到依赖Dapper,你也应该安装 Dapper nuget包进入主工程
然后打包就可以看到依赖Dapper在里面
============================================= ============
另外,如果你不希望引用的项目成为依赖nuget包,而只是一个程序集dll,你可以参考