Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I force Visual Studio to use only a Release build configuration for my production publish profile?

I have two publish profiles defined for my project in Visual Studio 2010: one uses ftp for production and the other copies to my local file system for debugging and day to day development.

I have web.config transformations in place for debug and release build configurations. My project is a Facebook application where I set the application ID and secret depending on the deployment.

I would like to be able to enforce a rule such that it is impossible to use the production ftp publish profile with the debug build configuration. This combination would be disastrous and entirely break my production environment.

How can I enforce this rule?

I am open to alternative deployment methods, but am pretty happy with the simplicity of what I have now with the exception of the potential for overlooking the build configuration when pushing to production.

like image 764
Pat James Avatar asked Mar 08 '11 18:03

Pat James


People also ask

How do I put Visual Studio in release mode?

In Solution Explorer, right-click the project and choose Properties. In the side pane, choose Build (or Compile in Visual Basic). In the Configuration list at the top, choose Debug or Release.

How do I change the build configuration code in Visual Studio?

You can use the Configuration Manager dialog box to select or modify existing build configurations, or to create new ones. To open the Configuration Manager dialog box, in Solution Explorer, right-click on the solution node to open the shortcut menu for the solution, and then choose Configuration Manager.

What are debug and release build configurations?

A Debug configuration supports the debugging of an app, and a Release configuration builds a version of the app that can be deployed.


1 Answers

I don't need to use publish for anything but production. You said that you publish Debug builds to other servers, so my solution won't work for you, but it may work for others without that need.

You can effectively enforce Release build on publish by breaking the Web.Debug.config transform. Any syntax error will do, but I prefer this change to the root tag:

<configuration_ONLY_PUBLISH_IN_RELEASE_CONFIG!! xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

When someone tries to publish in Debug, they'll get an error with that tag, pointing them to the solution.

Note that you can still build and run locally with Debug build, just not publish.

like image 200
Jerph Avatar answered Sep 27 '22 20:09

Jerph