Build Events per Configuration

I probably just overlooked it, or couldn’t figure out how to work it, but it appears that Build Events for a project are not connected to a configuration.

Since I want a “Deploy” config that copies files somewhere after a build, and a “No_Deploy” config that doesn’t, I started digging into the .csproj file.

The Post-build events are in a section that looks like this:

<PropertyGroup>
<PostBuildEvent>
copy $(TargetPath) c:\bin\
</PostBuildEvent>
</PropertyGroup>

Seemed pretty simple to use the Condition attribute on this PropertyGroup item, same as on other PropertyGroup items:

<PropertyGroup Condition=”‘$(Configuration)’ != debug_nodeploy'”>
<PostBuildEvent>
copy $(TargetPath) c:\bin\
</PostBuildEvent>
</PropertyGroup>

Seems to work as expected.  I wonder if VS will overwrite this at some point?

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you human? * Time limit is exhausted. Please reload CAPTCHA.

Protected with IP Blacklist CloudIP Blacklist Cloud