简体   繁体   English

具有NuGet依赖项的参考DLL

[英]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.

相关问题 重新安装nuget时出现多个dll参考失败 - Multiple dll reference failure on nuget reinstall 我应该使用NuGet还是DLL参考? - Should I use NuGet or DLL reference? NuGet:在不创建引用的情况下复制 .DLL 文件? - NuGet: Copying .DLL file without creating a reference? 如何将 dll 作为引用包含在 nuget 中,当 nuget 添加到项目时,该引用也被复制为引用 - How do I include dll as reference in nuget that also gets copied as reference when nuget added to project 嵌入vs引用我的依赖项:.NET / NuGet包的最佳实践? - Embed vs reference my dependencies: Best practices for .NET/NuGet package? Nuget:用于删除“ uninstall.ps1”中的DLL参考的脚本 - Nuget: script for removing a DLL reference in 'uninstall.ps1' NuGet包无法为lib目录中的DLL添加对项目的引用 - NuGet Package fails to add reference to project for DLL inside lib directory 覆盖NuGet解决方案的DLL对核心库的引用 - Overriding a NuGet solution's DLL's reference to a core library DLL 参考仅在 NuGet 在服务器上还原后有效 - DLL Reference Only Works After NuGet Restore on Server 避免添加 nuget 包引用以支持程序集引用的可能性,包括。 依赖? - Possibility to avoid adding nuget package reference in favor of assembly reference incl. dependencies?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM