Post Build event with condition

不问归期 提交于 2019-12-07 07:14:36

问题


Having the need to add a condition to the Post Build event in my Visual Studio 2013 project, I ended up with the following:

<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
    <PostBuildEvent>"$(SolutionDir)..\Deploy\Build\sign-bin.cmd"</PostBuildEvent>
</PropertyGroup>

I've added the condition Condition=" '$(OS)' == 'Windows_NT' " manually with a text editor to the CSPROJ file.

This works as expected, my solution builds successfully both in Visual Studio as well as in Travis CI.

What doesn't work:

When editing the Post Build event inside Visual Studio in the graphical editor, it seems to ignore the condition and simply stores the event twice:

<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
    <PostBuildEvent>"$(SolutionDir)..\Deploy\Build\sign-bin.cmd"</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
    <PostBuildEvent>"$(SolutionDir)..\Deploy\Build\sign-bin.cmd"</PostBuildEvent>
</PropertyGroup>

It doesn't matter whether I add the condition to the <PropertyGroup> node or the <PostBuildEvent> node.

In both cases the nodes are duplicated by Visual Studio upon saving.

My questions:

Any chance to somehow add the ability to ignore my Post Build event (which is the reason for the condition) on Travis?

Any chance to somehow tell Visual Studio to not duplicate the node with condition upon saving?

来源:https://stackoverflow.com/questions/30558600/post-build-event-with-condition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!