MSBuild exec任务,退出代码为空

MSBuild exec任务,退出代码为空,msbuild,exec,exit-code,Msbuild,Exec,Exit Code,我有以下exec任务,执行assemblyinfo.cs文件的签入。我试图返回退出代码,但由于某些原因,它总是空的 <!--Checkin if all succeeded--> <Exec Condition=" '$(LocalCompilationSuccess)' != 'Failed' and '$(LocalTestSuccess)' != 'Failed' " ContinueOnError="True" Command='&q

我有以下exec任务,执行assemblyinfo.cs文件的签入。我试图返回退出代码,但由于某些原因,它总是空的

<!--Checkin if all succeeded-->
<Exec Condition=" '$(LocalCompilationSuccess)' != 'Failed' and '$(LocalTestSuccess)' != 'Failed' " ContinueOnError="True"
              Command='&quot;$(TfCommand)&quot; checkin /recursive /comment:"$(NoCICheckInComment) $(BuildDefinitionName): build succeeded, checkin changes." /override:"TeamBuild $(BuildDefinitionName)" $/SomeProject/Trnk' WorkingDirectory="$(SolutionRoot)"  >
  <Output TaskParameter="ExitCode" PropertyName="ErrorCode"/>
</Exec>

两个都是空的。有什么建议吗?

一般来说,它的工作原理如您所示

作为参考,这里有一个更“独立”的示例:


<>你可能要考虑的一些事情:

  • 确保您的
    Exec
    甚至执行,即
    条件的计算结果为
    
    True

  • 使用
    消息
    -任务输出
    ErrorCode
    属性,查看它是否实际设置(设置为您期望的值)。但是,请确保MSBuild将显示输出,方法是使用
    Importance='high'
    或运行
    MSBuild.exe/v:d
    ,以启用详细消息


奇怪,请尝试
由于阻止调用该方法的条件而导致的问题。感谢mono/xbuild之后,我还必须在
任务中为要填充的属性指定
IgnoreExitCode=“true”
。此外,我建议设置
ignorestandarderrowarningformat=“true”
,原因是。否则,
ExitCode
可能是
-1
,而不是已启动进程的实际退出代码。
'%(ErrorCode.Identity)'
'$(ErrorCode)'
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <Target Name="help">
    <Exec ContinueOnError="True" Command='cmd.exe /c dir'>
       <Output TaskParameter="ExitCode" PropertyName="ErrorCode"/>
    </Exec>
    <Message Importance="high" Text="$(ErrorCode)"/>
  </Target>
</Project>