Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2013 Website Project - Change Configuration in Configuration Manager

I have Website Project in Visual Studio 2013. I have two Publishing Profiles, one for staging and the other for production. In Configuration Manager, I can create new Active Solution Configurations but cannot add new Configurations to my drop-down, Debug is the only option.

So now when I attempt to Publish using my production profile, the web.config is getting transformed by both the Web.Debug.Config and my web.Production.Config.

How do I add new Configurations to the dropdown?

enter image description here

like image 291
MyNameIsKo Avatar asked Mar 17 '23 01:03

MyNameIsKo


2 Answers

How do I add new Configurations to the dropdown?

You can't. At least not for the purpose you need to use these new configurations for.

I'll make the assumption that you really need to know this:

How can I publish a web site without the debug flag being applied to the web.config by the debug transform?

This is already happening, just in a confusing way.


When you publish the site using the Publish Web Site wizard it applies the appropriate transforms to the web.config. In your case, Web.Debug.Config and Web.Production.Config.

And now for the confusing part:

By default, web.debug.config actually removes the debug attribute from the web.config.

<compilation xdt:Transform="RemoveAttributes(debug)" />

This happens for legacy reasons to do with the missing Web Site project file and the underlying build tools.


If you want to stop the debug transformation being applied and you have no custom configuration in it, you can delete web.debug.config. Just be sure to add

<compilation xdt:Transform="RemoveAttributes(debug)" />

inside the <system.web> element of each of your environment specific transforms (web.Production.Config, etc).


My recommendation is:

  • Leave web.debug.config untouched. In its default state.
  • Create a publish profile for each environment.
  • Add a transform for each publish profile (web.<configuration>.config)
  • Put any environment specific configuration into the appropriate transform file.
like image 182
Chris O'Neill Avatar answered May 11 '23 11:05

Chris O'Neill


To get my publish settings working the way I wanted I had to:

  • Return web.debug.config back to it's default contents (I had some transforms in here that I was using for my staging environment)
  • For every publish profile in /App_Data/PublishProfiles/, right click and select Add Config Transform to create a new config file at the root of the site (note that it will not be nested under the default web.config unless the profile is titled debug or release, kinda odd if you ask me)
  • Add any relevant transforms to each of these new configs

Since all publish profiles in a website project seem to be stuck on a debug configuration, there was no way for me to avoid web.debug.config transforming my default web.config. With this solution, we simply don't use web.config for publish specific transforms.

I'd like to credit Chris O'Neill for his helpful, if verbose, answer that clued me into this solution.

like image 31
MyNameIsKo Avatar answered May 11 '23 12:05

MyNameIsKo