When I try to build my project with NCrunch, I keep getting problems like the following:
"The type 'Microsoft.Web.Administration.ServerManager' exists in both 'c:\Windows\assembly\GAC_MSIL\Microsoft.Web.Administration\7.9.0.0__31bf3856ad364e35\Microsoft.Web.Administration.dll' and 'e:\_SourceControl\framework\packages\Microsoft.Web.Administration.7.0.0.0\lib\net20\Microsoft.Web.Administration.dll
When I build using VS2013 or just through msbuild.exe, the build just runs fine. Other projects in the solution also just work with ncrunch.
I've been spending hours looking for a solution to this, so any ideas would be most welcome.
Is it possible you are making use of two different versions of the same DLL referenced within the same project space? Sometimes this can happen if:
Project A references Project B
Project A references Microsoft.Web.Administration (v7.0)
Project B references Microsoft.Web.Administration (v7.9)
I've found that MSBuild can be quite inconsistent in the way it handles these situations, depending upon how the references are structured within the solution. NCrunch does make some changes to references in order to set up workspaces for the projects when it builds them, so it's quite likely that this change in conditions is causing the error to surface where it isn't surfacing for your normal VS builds. Unfortunately trying to get NCrunch to work in exactly the same way as a foreground VS build isn't possible, so the solution here would be trying to find the mismatched references and correct them. Assemblies that manage to successfully build with reference mismatches can encounter runtime problems, so this is something you will want to sort out regardless of your use of NCrunch.
I'd suggest doing a full text search on your codebase for "Microsoft.Web.Administration". The references should be declared inside your project XML. Make sure that when you reference this DLL, you do so using its correct strong name. MSBuild and the CLR will both resort to the GAC installed version of a strongly named assembly before searching other locations - so make sure that the declarations of these references are consistent throughout your solution.