Mcloving
Mcloving

Reputation: 1400

Multiple Publishing web.configs in Visual Studio 2010

In my settings, I have two String settings and one connection string. These obviously show and are changeable in the web.config. On top of that, not in the settings, but in the web.config, I have my entity framework connection String.

I also have 4 different publishing profiles (Addresses to publish my website to)

However: They all run off the same config file. So I have to change it manually before each publish. And if i forget/get it wrong, the entire site siezes to work.

Is there any way, to link publish specific web.config files. So that each publish profile generates the correct version, with its correct values/connection strings.

Ive come accross transforms, and pubxml, but nothing seems to make sense or work, or even be compatible with VS 2010.

If anyone can link or explain the path i should be taking to achieve this, i would be gratefully happy. I have spent days trying.

Upvotes: 0

Views: 254

Answers (3)

Jimmy
Jimmy

Reputation: 28376

The .pubxml and profile-oriented transforms are available in VS2010 through the Azure SDK Bundle. Here's how to do it:

  1. Have VS2010 installed. I'm using VS2010 Ultimate RTM (had to set up a new machine).
  2. Install the Azure SDK. I'm doing this through the Web Platform Installer; it looks like the last Azure SDK for VS2010 was 2.1. This includes SP1 (if you don't have it already), a further hotfix, and the out-of-band tooling update to support .pubxml, as well as a bunch of other things. If you just want the VS components, I think you can find them at http://azure.microsoft.com/en-us/downloads/archive-net-downloads/ under July 2013 (Version 2.1)
  3. At this point, you can create publish profiles as many of the newer blog posts show: Create a new profile

  4. And add transforms for them:

    Add config transform

  5. And preview the transforming effects of each profile's transform (which does take into account the Debug/Release ones as well):

    Preview transform

Upvotes: 0

Eric Scherrer
Eric Scherrer

Reputation: 3388

I would take a second look at web config transformations - it was built for exactly this and is most definitely supported in VS 2010. Alternatively I have worked with a deployment setup where there was a custom utility that did exactly what web config transforms does by running as a build task. Using the two I would still recommend web config transformations due to it being well documented.

Upvotes: 0

Kinexus
Kinexus

Reputation: 12904

You can create a new configuration in the Configuration Manager and then create the corresponding config for that profile.

When deploying, if you change the configuration to the correct one, it will then pick up the appropriate config.

How to: Transform Web.config When Deploying a Web Application Project

Upvotes: 1

Related Questions