Question

I have been scouring the internet for an answer on this and could really use the help.

I've already looked at other posts regarding this error and none of those answers helped me.

The full error is,

The type 'xxx' is defined in an assembly that is not referenced. You must add a reference to assembly 'xxx, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

The solution builds fine locally, but the error occurs when I trigger a build on the build server.

Here's what I've done so far in an attempt to resolve this:

  • Ensured all project references are correct(Had an Architect review it with me)
  • Changed the 'SpecificVersion' property to true
  • Removed the reference and added it back(In VS2012 and edited the .csproj file itself)
  • Built solution locally on the build server, it passes
  • EDIT - I should also mention I have built this solution on two different build servers and still get the same error

I'm using VS2012 and TFS2012 to do this.

I would really appreciate any help, thanks.

*UPDATE:*I just did an MSBuild on the build server but changed the configuration to "Release" and was able to reproduce parts of the error. Some key differences though is that the version it's looking for is suddenly 1.3.1.15 instead of 0.0.0.0 and the PublicKeyToken is no longer null. Does anyone know what this could mean? The assembly's version is supposed to be 0.0.0.0.

Was it helpful?

Solution

So after putting in a few more hours with my Architect, we found the issue. Our developers had multiple copies of the same dll buried in various folders in our Source Control. One of the projects was referencing the incorrect .dll.

After fixing the references and removing the extra uneeded .dlls, the error is gone and our builds are finally working! :)

OTHER TIPS

You mentioned that you tried building solution on the test server. Did you use visual studio 2012 to build the solution or did you actually run msbuild?

The accurate test would be to use msbuild similar to this:

MSBuild MySolution.sln /p:Configuration="Debug" /p:Platform="CPU Any"

You can actually get the exact command by looking at the build logs for TFS Build, it will list the build command it executed and simply run it yourself (you'll need to remove extra stuff TFS Build adds for logging)

After that you can run the same command on your local machine and see if it passes.

Another thing to try is to set "copy local" for all assemblies in the project.

Hope this helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top