Make Debug/Release Build Configuration with 1 Click Publish dependent on the selected Publish Profile
Asked Answered
R

2

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. :-)

Risk answered 21/4, 2011 at 1:6 Comment(6)
In the same boat, did you ever find a good solution?Raynard
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 or appSettings.Risk
Odd that they would separate Build Configuration selection from Publishing since that is when it is utilized. Thanks for your reply, still helps!Raynard
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.Bluefield
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.Scheel
This question also remains unanswered, so it is a duplicate.Scalenus
I
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/

Imperious answered 8/9, 2011 at 22:2 Comment(0)
N
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

Nativity answered 5/2, 2013 at 22:25 Comment(1)
This is the solution you want.Scalenus

© 2022 - 2024 — McMap. All rights reserved.