I have installed entity framework v 184.108.40.206 nuget package.
When building solution locally, it works great without any issues. But, when I check in the code and when the build runs on server, it throws below compilation error.
Primary reference "EntityFramework, Version=220.127.116.11, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL".
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "EntityFramework, Version=18.104.22.168, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
Any suggestions would be appreciated. Thank you in advance.
The problem you probably have is that your build agent isn't fetching the Nuget package for you.
In my company this is caused by the service account that the build agent is running under not having the corporate proxy set by default.
So firstly you need to run the build agent service as a real user (i.e. not Network Service or Local Service). Then you need to log in to the build agent as that user and set the proxy by hand. Hopefully you can use your own proxy settings.
It's been a long time since I did this, but I also seem to remember that there might be some Visual Studio setting that is off by default about Nuget package restore. So what I generally do when I'm troubleshooting this kind of thing is try to build the solution as the build agent user on the build agent from within Visual Studio. Once you can do that successfully the build should work. It should also work as you add Nuget packages.
If this completely fails to work because you can't get the build agent user through the proxy then you can always create a local Nuget file share and copy the packages to that share, then add the share to your Nuget config. This is configured in the
nuget.config file. Mine looks like this:
<?xml version="1.0" encoding="utf-8"?> <configuration> <solution> <add key="disableSourceControlIntegration" value="true" /> </solution> <packageSources> <add key="nuget.org" value="https://www.nuget.org/api/v2/" /> <add key="Private package source" value="\\BuildController\nuget\Packages" /> </packageSources> </configuration>
The second package source is a file share where we put our own packages.