在构建发布配置之前提示?
Prompting before building a Release configuration?
我有一些特定的 post-build 操作绑定到发布配置,部署到测试环境。有没有办法在有人使用特定项目的发布配置在本地构建之前启用弹出警告?如果没有,我可以让我的 post-build 操作更智能。
您需要使用自定义 MSBuild 任务。这是一个帮助您入门的内联任务。
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003' ToolsVersion="12.0">
<UsingTask TaskName="ShowConfirmationPopup" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup>
<Message ParameterType="System.String" Required="true" />
<Title ParameterType="System.String" Required="false" />
<Result ParameterType="System.Boolean" Output="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Windows.Forms"/>
<Using Namespace="System.Windows.Forms" />
<Code Type="Fragment" Language="cs"><![CDATA[
Result = MessageBox.Show(Message, Title ?? "MSBuild Confirmation",
MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1) == DialogResult.Yes;
]]></Code>
</Task>
</UsingTask>
<Target Name="PromptReleaseBuild" BeforeTargets="PrepareForBuild" Condition="'$(Configuration)' == 'Release'">
<ShowConfirmationPopup Message="Do Release Build?">
<Output TaskParameter="Result" PropertyName="DoReleaseBuild" />
</ShowConfirmationPopup>
<Error Text="Prompt refused" Condition="'$(DoReleaseBuild)' != 'true'" />
</Target>
</Project>
我有一些特定的 post-build 操作绑定到发布配置,部署到测试环境。有没有办法在有人使用特定项目的发布配置在本地构建之前启用弹出警告?如果没有,我可以让我的 post-build 操作更智能。
您需要使用自定义 MSBuild 任务。这是一个帮助您入门的内联任务。
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003' ToolsVersion="12.0">
<UsingTask TaskName="ShowConfirmationPopup" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup>
<Message ParameterType="System.String" Required="true" />
<Title ParameterType="System.String" Required="false" />
<Result ParameterType="System.Boolean" Output="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Windows.Forms"/>
<Using Namespace="System.Windows.Forms" />
<Code Type="Fragment" Language="cs"><![CDATA[
Result = MessageBox.Show(Message, Title ?? "MSBuild Confirmation",
MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1) == DialogResult.Yes;
]]></Code>
</Task>
</UsingTask>
<Target Name="PromptReleaseBuild" BeforeTargets="PrepareForBuild" Condition="'$(Configuration)' == 'Release'">
<ShowConfirmationPopup Message="Do Release Build?">
<Output TaskParameter="Result" PropertyName="DoReleaseBuild" />
</ShowConfirmationPopup>
<Error Text="Prompt refused" Condition="'$(DoReleaseBuild)' != 'true'" />
</Target>
</Project>