问题
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