简体   繁体   中英

Referenced project dependency is copying from GAC instead of NuGet package folder

I'm having a strange issue where I have a Windows Service project (A) that references another project in the solution (B). The project B has a reference to a nuget package (in this case, protobuf-net); it is correctly referencing the path in the packages folder. However, when I build the Windows Service project A, the DLL that gets copied is a different version (which is coming from the GAC).

What's the best way to resolve this, and ensure that it's properly copying the dependency.

I tried deleting the associated folder in the packages folder and then rebuilding Project B; this did result in nuget automatically downloading the files again, however I see that the reference in Visual Studio for Project B was updated to an older version in the GAC. I had to remove the reference in the packages.config file, and then add it again using nuget to get it to update to using the correct path in the packages folder.

I ran into this same problem and resolved it by setting "Copy Local" to false for the reference to Project B in Project A.

In my case, all of my projects have the same Output path. I have an EXE (project A) and a DLL (project B). The DLL has a reference to a Nuget package. When I would compile just the DLL it would copy the referenced Nuget DLL from the packages folder to the output folder.

However, when I compiled the EXE it would overwrite that Nuget DLL with an older version from the GAC. Setting "Copy Local" to False fixed it so that the Nuget DLL only gets copied when the DLL is compiled and not when the EXE is compiled.

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