MSBuild重置错误标志
我有一个任务在第一次调用时总是失败,因为它缺少一个文件,但我有一个OneError任务,它创建文件并恢复其他任务,但构建总是失败,因为它处于错误状态。在OneError目标中是否仍有重置此错误状态的方法 声明如下: 如果目标元素的任务之一失败,并且ContinueOnError属性设置为error和stop(或false),则MSBuild将执行OnError元素 也就是说,如果我将ContinueOnError设置为警告和continue(或true),我将无法执行任务 这是我的密码:MSBuild重置错误标志,msbuild,Msbuild,我有一个任务在第一次调用时总是失败,因为它缺少一个文件,但我有一个OneError任务,它创建文件并恢复其他任务,但构建总是失败,因为它处于错误状态。在OneError目标中是否仍有重置此错误状态的方法 声明如下: 如果目标元素的任务之一失败,并且ContinueOnError属性设置为error和stop(或false),则MSBuild将执行OnError元素 也就是说,如果我将ContinueOnError设置为警告和continue(或true),我将无法执行任务 这是我的密码: <
<PropertyGroup>
<AppVersion>0.0.0</AppVersion>
<ChangelogFileName>Changelog_$(AppVersion).html</ChangelogFileName>
<AppCastLocation>http://test/AppCast.xml</AppCastLocation>
</PropertyGroup>
<!-- AppCastCreation target is the starting point, it attempts to download
the AppCast.xml (Target=AppCastDownload), if it fails then we create
a new AppCast.xml (Target=AppCastNew) and then update the AppCast with
the new version bneing deployed (Target=AppCastUpdate) -->
<Target Name="AppCastCreation">
<CallTarget Targets="AppCastDownload;AppCastUpdate" RunEachTargetSeparately="True" />
</Target>
<Target Name="AppCastDownload">
<!-- Download latest AppCast.xml if it doesn't exist, then create a new one -->
<WebDownload FileUri="$(AppCastLocation)" FileName="AppCast.xml" />
<OnError ExecuteTargets="AppCastNew"/>
</Target>
<Target Name="AppCastNew">
<!-- Create a new AppCast.xml -->
<Message Text="Creating new AppCast.xml" />
<Exec Command='python $(AppCastPublisherPath)AppCastPublisher.py new AppCast.xml "Changelog" "$(AppCastLocation)"'/>
<OnError ExecuteTargets="MessageErrorHandler"/>
</Target>
<Target Name="AppCastUpdate" DependsOnTargets="AppCastDownload">
<Message Text="Updating AppCast.xml with Version $(AppVersion)" />
<!-- Create changeset info and upload -->
<Exec Command="python GetJenkinsChangeset.py -html -out $(ChangelogFileName)" />
<OnError ExecuteTargets="MessageErrorHandler"/>
</Target>
0.0.0
Changelog_$(AppVersion).html
http://test/AppCast.xml
因此,我是否可以重置AppCastNew目标或可能执行相同结果的其他工作流中的错误状态?而不是使用
而不是使用您错误地使用了OneError任务。你不能在访问文件之前检查一下吗?这将是一个更干净的解决方案。@D.R.OnError是如何被滥用的?最好事先检查文件是否存在,但如何使用URL实现这一点?您误用了OnError任务。你不能在访问文件之前检查一下吗?这将是一个更干净的解决方案。@D.R.OnError是如何被滥用的?最好事先检查文件是否存在,但如何使用URL实现这一点?
<WebDownload FileUri="$(AppCastLocation)" FileName="AppCast.xml" />
<OnError ExecuteTargets="AppCastNew"/>
<WebDownload ContinueOnError="WarnAndContinue" FileUri="$(AppCastLocation)" FileName="AppCast.xml" />
<CallTarget Condition=" '$(MSBuildLastTaskResult)' == 'False' " Targets="AppCastNew"/>