[英]Reference DLL with NuGet dependencies
Let's say I build a project named B as B.dll. 假设我建立了一个名为B的项目B.dll。 Project B uses several NuGet packages.
项目B使用多个NuGet软件包。 B.dll is referenced in another project A. How can I automatically add the referenced NuGet dependencies to project A?
在另一个项目A中引用了B.dll。如何将引用的NuGet依赖项自动添加到项目A中? I don't want to run a NuGet server.
我不想运行NuGet服务器。
How can I automatically add the referenced NuGet dependencies to project A?
如何自动将引用的NuGet依赖项添加到项目A? I don't want to run a NuGet server.
我不想运行NuGet服务器。
It depends on where you want to add those NuGet dependencies for the project A, if you add them to the project A s output, you can just use a copy command line in the build event to copy those dependencies to the project A
s output,like: 这取决于您要为项目A添加这些NuGet依赖项的位置,如果将它们添加到项目A
s output, you can just use a copy command line in the build event to copy those dependencies to the project A
的输出中,喜欢:
copy /Y "$(TargetDir)*.dll" "$(SolutionDir)\...\bin\...\"
If you want to add those dependencies to the References node of project A automatically , this is almost impossible. 如果要将这些依赖项自动添加到项目A的“引用”节点,则几乎是不可能的。 If you want to automate that, you have to do this operations via NuGet CLI.
如果要使其自动化,则必须通过NuGet CLI进行此操作。 Since Install package on NuGet CLI will not modify the reference of project, so we could not automate the operation install package to update the reference of the project.
由于在NuGet CLI上安装软件包不会修改项目的引用,因此我们无法自动执行操作安装软件包来更新项目的引用。
Check this thread for some more details. 检查此线程以获取更多详细信息。
So, it seems unlikely if you want to fully automated to add the referenced NuGet dependencies to project A. As a workaround, you can set the path of the \\packages
folder of project B to the nuget source, then you can add those nuget package to the project A with nuget package management UI, so that you do not need to run a nuget server. 因此,如果要完全自动化地将引用的NuGet依赖项添加到项目A中,似乎不太可能。作为一种解决方法,可以将项目B的
\\packages
文件夹的路径设置为nuget源,然后可以添加这些nuget包。带有nuget包管理UI的项目A,因此您无需运行nuget服务器。
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.