8

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.

Pat James
  • 4,348
  • 26
  • 39
  • so...uh...I guess the answer is "no"? – Pat James Mar 18 '11 at 18:01
  • Did you come up with a solution for this? – Craig May 09 '11 at 20:08
  • Nope. I have come to accept the conclusion that it is not possible. I will self-answer as such. – Pat James May 20 '11 at 14:39
  • Thanks, I came to the same conclusion. To help reduce accidents, I added an appSetting key called "ApplicationTitle" which I set differently in each transformation file. When the build configuration is set to DEBUG, the application title is "DEBUG MODE". Simple, but thought it might be useful someone. – Craig May 24 '11 at 10:44

3 Answers3

8

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.

Jerph
  • 4,572
  • 3
  • 42
  • 41
  • This was helpful. I can only publish to debug/test servers anyway but it set up only the required publish configuration – MikeJ May 18 '12 at 20:10
2

I have come to accept the conclusion that it is not possible, so apparently the answer is....NO

Pat James
  • 4,348
  • 26
  • 39
  • 1
    This is not true anymore - check out [Jeff's response on Billkamm's question](http://stackoverflow.com/questions/5410278/link-build-configuration-to-a-publish-profile); basically you just need to install http://blogs.msdn.com/b/webdev/archive/2012/06/15/visual-studio-2010-web-publish-updates.aspx – nikib3ro Mar 13 '13 at 20:56
0

I posted a related question here: Link build configuration to a publish profile asking why you can't do it. Hopefully someone will know if Microsoft plans on changing this.

Community
  • 1
  • 1
Billkamm
  • 1,064
  • 1
  • 9
  • 22