我有一个自定义pubxml文件,其中包含一个执行powershell脚本的Target。此powershell命令在部署我的站点之前成功运行。
如果powershell脚本中发生错误,则输出将放在“输出”窗口中,但构建将继续,最终消息将为“发布:1”成功。如果我的powershell脚本错误,如何停止发布?
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PipelineDependsOn>
CopyConfigFiles;
$(PipelineDependsOn);
</PipelineDependsOn>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl></publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
</PropertyGroup>
<Target Name="CopyConfigFiles">
<Message Text="********************************** Deploying Config Files ***********************************" Importance="high"/>
<Exec Command="powershell.exe -ExecutionPolicy ByPass -File "$(SolutionDir)/Config/CopyConfigFiles.ps1" -ConfigSource "$(SolutionDir)/Config/""/>
</Target>
答案 0 :(得分:0)
很明显!
如果您的powershell脚本返回退出代码,则错误将阻止发布。只需捕获powershell异常并返回exit命令:
onBackPressed()