random thoughts and discussions on the things that interest me

TeamCity, MSBuild 4.0, a 64bit Server, and Could Not Load File or Assembly

I’ve been spending some time recently setting up TeamCity for continuous integration and stumbled upon an annoying issue that had me stumped for a while.

Following a simple update to a build script where I changed the way paths were resolved my build started failing. The error message was (cut down):,5): error MSB4062: The "xxx" task could not be loaded 
from the assembly C:\Program Files%28x86%29\ .. \xxx.dll. Could not load 
file or assembly. The system cannot find the file specified.

After some serious head scratching and a lot of Google time it turns out that this is a bug with MSBuild 4.0.┬áBasically MSBuild 4.0 can’t handle paths with parentheses in certain situations. As the path on the server to the build files was under c:\Program Files (x86)\ it was just falling over with a file not found exception. The work around suggested by Microsoft is to compensate by decoding the path reference in your build script. In my case this meant changing from this:

  TaskName="xxx" />

to this:

  TaskName="xxx" />

Simples, no?

No Responses to “TeamCity, MSBuild 4.0, a 64bit Server, and Could Not Load File or Assembly”

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.