1

当我将我的 Web 部署项目从 VS2008 升级到 VS2010 测试版时,我能够在我的开发箱上本地执行构建。但是,当我尝试在 TeamCity 构建服务器上执行构建时,我开始收到以下异常:

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)". 

我确实在构建服务器上安装了 Web 部署项目插件,并且确实将开发框上的 C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications 目录复制到了 C:\Program Files构建服务器上的 \MSBuild\Microsoft\VisualStudio\v10.0\ 目录。注意:我的开发盒是 64 位的,构建服务器是 32 位的。

我无法弄清楚为什么在构建服务器上的行为与在我的开发机器上的行为不同。有人有想法么?

谢谢,史蒂夫

4

1 回答 1

3

MSBuild 4在构建过程中未使用(未安装和/或 TeamCity 链接到 MSBuild 3.5)。

您必须确保这MSBuild 4是构建服务器上使用的版本。

说明(供参考)

Web Deployment Project 2010使用MSBuild 4like的新功能Property function。如果使用先前版本的 MSBuild,则不会评估属性函数,并且会发生坏事。

如果您查看文件Microsoft.WebDeployment.targets,您应该会看到以下声明:

<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>

在 MSBuild 3.5 中,propertySourceWebProjectIndexSourceWebProjectPathuse 属性函数不会被评估,因此条件 onSourceWebProjectPathBeginWith也无法被评估,从而导致错误:

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)". 
于 2010-05-26T07:16:42.767 回答