Build Fails Entity Framework - Compilation Error

c#-6.0 entity-framework entity-framework-6 tfs tfsbuild


I have installed entity framework v 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=, 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=, 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.

8/1/2017 2:37:12 AM

Popular Answer

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"?>
    <add key="disableSourceControlIntegration" value="true" />
    <add key="" value="" />
    <add key="Private package source" value="\\BuildController\nuget\Packages" />

The second package source is a file share where we put our own packages.

8/1/2017 2:50:04 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow