Cameron Fletcher

Random thoughts and dicussions 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):

default.build(83,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 systemcannot 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:

<UsingTask AssemblyFile="$(BuildFolder)\xxx.dll" TaskName="xxx"/> 

to this: 

<UsingTask AssemblyFile="$([MSBuild]::Unescape('$(BuildFolder)'))\xxx.dll" TaskName="xxx"/> 

So there we go. There is a connect issue for this bug here but I just thought I'd put this out there because it frustrated me no end until I found out what the issue was. Coincidentally, and for those that are interested, it was build #69 that contained the fix.

Posted: Feb 23 2011, 06:52 by flet0496 | Comments (2) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: .NET

Comments

Comments are closed