MSBuild exec任务,退出代码为空 [英] MSBuild exec task, exit code empty
问题描述
我有以下exec任务,用于执行assemblyinfo.cs文件的签入.我正在尝试返回退出代码,但由于某种原因,它始终为空.
I have the following exec task, performing checkin of assemblyinfo.cs files. I'm trying to return the exit code, but for some reason it is always empty.
<!--Checkin if all succeeded-->
<Exec Condition=" '$(LocalCompilationSuccess)' != 'Failed' and '$(LocalTestSuccess)' != 'Failed' " ContinueOnError="True"
Command='"$(TfCommand)" checkin /recursive /comment:"$(NoCICheckInComment) $(BuildDefinitionName): build succeeded, checkin changes." /override:"TeamBuild $(BuildDefinitionName)" $/SomeProject/Trnk' WorkingDirectory="$(SolutionRoot)" >
<Output TaskParameter="ExitCode" PropertyName="ErrorCode"/>
</Exec>
我试图用两种方式读取退出代码:
I've tried to read the exit code in 2 ways:
'%(ErrorCode.Identity)'
'$(ErrorCode)'
两个都是空的.有什么建议吗?
Both are empty. Any suggestions?
推荐答案
总的来说,它如您所显示的那样起作用.
In general it works as you have shown.
作为参考,这是一个更独立的"示例:
For reference, here is a more "selfcontained" example:
<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>
不过,您可能需要考虑以下几点:
A couple of things you may want to consider however:
-
确保您的
Exec
甚至执行,即Condition
的计算结果为True
.
Make sure your
Exec
even executes, that isCondition
evaluates toTrue
.
使用Message
-Task输出ErrorCode
属性,以查看是否已实际设置(为您期望的值).但是,通过使用Importance='high'
或运行msbuild.exe /v:d
启用详细消息,确保MSBuild将显示输出.
Output the ErrorCode
property using the Message
-Task, to see if it is actually set (to the value you expect). However, make sure MSBuild will show the output, by either using Importance='high'
or by running msbuild.exe /v:d
to enable detailed messages.
这篇关于MSBuild exec任务,退出代码为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!