简体   繁体   中英

Reference DLL with NuGet dependencies

Let's say I build a project named B as B.dll. Project B uses several NuGet packages. B.dll is referenced in another project A. How can I automatically add the referenced NuGet dependencies to project A? I don't want to run a NuGet server.

How can I automatically add the referenced NuGet dependencies to project A? I don't want to run a NuGet server.

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:

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. If you want to automate that, you have to do this operations via 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.

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.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM