MSBuild exec任务,退出代码为空 [英] MSBuild exec task, exit code empty

查看:68
本文介绍了MSBuild exec任务,退出代码为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下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='&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>

我试图用两种方式读取退出代码:

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 is Condition evaluates to True.

使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆