Allow only release build to be published

We have a WPF application that we distribute with click-once deployment. The update feature is exactly what we need for our product. Getting the new build from Development into Production is easy, just publish.

The problem is that we only want Release builds to be published. Config transformation, code optimisation and custom icons are some of the main reasons we want to publish a Release build. Sometimes we forget to change the configuration and a Debug build is released into the wild.

As a safety net we added the BeforePublish build target to the project.

<Target Name="BeforePublish">
    <Error Condition="'$(Configuration)'!='Release'" 
           Text="Only Release build can be published" />
</Target>

Now when we try to publish without setting the configuration to Release the build fails.

publish.debug.fails

Since this is a very small project we haven’t setup automated build. The errors should keep us safe for now.

About erictummers

My work as a recruited developer changes almost every month. I like challenges and sharing the solutions with others. On my blog I’ll mostly post about my work, but expect an occasional home project, productivity tip and tooling review.
This entry was posted in Development and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s