25

This is almost a duplicate of Link build configuration to a publish profile, but that question was not answered...


I have 2 1 Click Publish configurations for my Web Application:

  1. Test Server
  2. Production Server

If I select Build => Configuration Manager => Release and then click the Publish button my application will be published with a release configuration (and visa versa) - without regard to the current Publish profile selected.

But what I REALLY want is...

To set the appropriate Build Configuration from the 1 Click Publish settings. Test Server should be published with my Debug settings and Production Server should be published with the Release settings.

I shouldn't have to make the change from within the Configuration Manager. But I Do.

So, I have 2 questions:

Am I just doing it wrong? Based on a little note in the Publish Settings stating "Use Build Configuration Manager to change configuration" this seems like this is exactly how it is intended to work.

booya

Is there another way of having 2 publish profiles, one with a Debug config and one with a Release config?


The only thing I'm using the debug/release build configurations for is for my Config Transforms that have different connection strings. So, alternative, but still 1 Click, publishing solutions are acceptable. :-)

Community
  • 1
  • 1
David Murdoch
  • 87,823
  • 39
  • 148
  • 191
  • In the same boat, did you ever find a good solution? – Craig May 09 '11 at 20:05
  • 2
    Nope, its just not designed for this approach. Since all I needed to do was change the connection string being used by my application I now just check if the `Environment.MachineName.Equals("MyLiveServersName")` and choose my ConnectionString based on that. For now, mine is just hard-coded into the application itself but you could (and probably should) go as far as to set your live servers' name(s) in your web/app.config via a [ConfigurationSection](http://msdn.microsoft.com/en-us/library/system.configuration.configurationsection.aspx) or appSettings. – David Murdoch May 09 '11 at 20:17
  • Odd that they would separate Build Configuration selection from Publishing since that is when it is utilized. Thanks for your reply, still helps! – Craig May 09 '11 at 20:21
  • I have to say that this really annoys me. I spent half a day trying to figure out why I couldn't connect to the DB. It was because I was using the wrong config due to this issue. – Andrew Oct 07 '11 at 08:10
  • David, check out @Jeff 's answer - it's the best solution to the problem (I've just used it), and if it helps you accept it as answer. – nikib3ro Mar 13 '13 at 20:52
  • This question also remains unanswered, so it is a duplicate. – Steffe Oct 30 '13 at 07:37

2 Answers2

2

It's possible to do another way by having multiple Web Deployment Packages.

Basically create two different projects and each one will compile and set the asp.net build config and output. Then script the deployment as part of it.

Bit hacky (wish the publish profiles could set the build config as you wished).

Other than that I normally do via powershell scripts and kick off from my desktop deploy that does all the appropriate compiling and deployment scenarios.

http://msdn.microsoft.com/en-us/magazine/cc163448.aspx

http://johnnycoder.com/blog/2010/01/07/deploy-aspnet-web-applications-with-web-deployment-projects/

Justin King
  • 1,428
  • 12
  • 14
1

I was able to get this to work by installing the Visual Studio Web Publish Update. This update allows you to tie a build configuration to a specific publish profile.

http://msdn.microsoft.com/en-us/library/jj161045.aspx

Publish Profile

Jeff
  • 48
  • 5