views:

524

answers:

4

I have a 2008 Solution that is giving me all sorts of missing assembly reference errors when we try to build it with MSBuild. I brought up the solution in Visual Studio and at first I got the same compile errors. Lots of missing references, so I went to the projects in question and expanded the References group and saw the exclamation point inside a yellow triangle next to a couple of references. I clicked on the reference, so that I could verify the path of the reference in the properties window and magically the missing reference icon disappeared. No prompt to check-out. No prompt to save anything. The reference magically resolved. I also noticed that the path was correct before and after the missing reference icon disapeared. I did this for every missing reference (about 6 of them) and hit Build Solution and everything compiled fine. I've reloaded the solution in Visual Studio several times after that and it still works, however, MSBuild is still throwing the same compile errors.

What gives? Why did Visual Studio 2008 Team System Developer Edition magically resolve these references and compile the solution and MSBuild still cannot find them? Any help would be appreciated. Thanks.

A: 

Since you said "No prompt to check-out", I take it that you're using some sort of Source Control management? If so, then there may be a couple of things to check:

  • Are the references correct within the checked-in source code?
  • Do all the paths referenced exist on the machine where it's getting built?
CAbbott
Agree, check the paths on the build machine. The output logs should tell you exactly what to look for.
DaveE
A: 

Try to open the solution from another PC, eventually with an Express flavor of VS2008, this way you might get a more descriptive error message. My last resort is to recreate the project/solution from scratch.

alexandrul
A: 

I had a problem like this a few years ago. What are the assemblies you are missing? Do they belong to a Microsoft product e.g. SQL Server or Office?

The Visual Studio "Add Reference" dialog uses registry locations to store paths to assemblies (see "To display an assembly in the Add Reference dialog box" halfway down the page). This is in addition to assemblies stored in the GAC. If your assemblies reside in one of these locations it might cause this problem as I suspect that these are not checked by MSBuild.

Have a look at these locations to see if your assemblies are residing at one of these paths referenced in the registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx

If you want to be sure that you can find your assemblies consider adding a lib folder to your source tree. You can copy all the assemblies you depend on into that folder and reference them from there. This has the additional advantage that the references don't change if another developer opens the solution to his machine.

MikeD
A: 

The problem was fixed when we merged our development branch back up into the main branch. I have sneaking suspicion that the paths to the references were pointing to "/Dev/" in our main branch instead of "/Main/" and that VS 2008 was automatically updating the reference for us where MSBuild did not.

I think this might occur when you add a reference by file (using the Browse tab) instead of adding a reference by using the Project tab.

Billkamm