views:

315

answers:

1

When I upgraded my Web Deployment Project from VS2008 to the VS2010 beta version, I was able to execute the build locally on my development box. However, when I tried to execute the build on our TeamCity build server, I began getting the following exception:

C:\Program Files\MSBuild\Microsoft\WebDeployment\v10.0\Microsoft.WebDeployment.targets(162, 37): 
error MSB4086: A numeric comparison was attempted on "$(_SourceWebProjectPath.Length)" 
that evaluates to "" instead of a number, in condition "'$(_SourceWebProjectPath)' != '' 
And $(_SourceWebProjectPath.Length) >= 4)". 

I did install the Web Deployment Project addin on my build server and I did copy over the C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications directory on my development box to the C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\ directory on the build server. Note: My dev box is 64bit and the build server 32bit.

I can't figure out why this is behaving differently on the build server than on my dev machine. Anyone have any ideas?

Thanks, Steve

+1  A: 

MSBuild 4 is not used during your build process (It is not installed and/or TeamCity is linked to MSBuild 3.5).

You have to make sure that MSBuild 4 is the version used on your build server.

Explanation (for information)

Web Deployment Project 2010 use new feature of MSBuild 4 like Property function. If a prior version of MSBuild is used the property function aren't evaluated and bad things happens.

If you look in the file Microsoft.WebDeployment.targets you should see this declaration :

<PropertyGroup Condition="'$(SourceWebProject)' != ''">
  <_SourceWebProjectIndex>
    $([MSBuild]::Add(1, $(SourceWebProject.LastIndexof('|'))))
  </_SourceWebProjectIndex>
  <_SourceWebProjectPath>
    $(SourceWebProject.SubString($(_SourceWebProjectIndex)))
  </_SourceWebProjectPath>
  <_SourceWebProjectPathBeginWith Condition="'$(_SourceWebProjectPath)' != '' And ($(_SourceWebProjectPath.Length) &gt;= 4)">
    $(_SourceWebProjectPath.SubString(0,4))
  </_SourceWebProjectPathBeginWith>
</PropertyGroup>

The property SourceWebProjectIndex and SourceWebProjectPath use property functions, with MSBuild 3.5 they aren't evaluated, so the condition on SourceWebProjectPathBeginWith couldn't be evaluated either resulting in the error :

C:\Program Files\MSBuild\Microsoft\WebDeployment\v10.0\Microsoft.WebDeployment.targets(162, 37): 
error MSB4086: A numeric comparison was attempted on "$(_SourceWebProjectPath.Length)" 
that evaluates to "" instead of a number, in condition "'$(_SourceWebProjectPath)' != '' 
And $(_SourceWebProjectPath.Length) >= 4)". 
madgnome
Thanks much. I am still having other issues, but your help fixed that one.
SteveBering