Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Both of these methods are extremely error prone and a simple typo can bring down your entire website. There is a better solution however, and this solution is to use which uses Web.Config transforms.

Web.Config transforms modify your web.config file depending on which Solution Configuration is selected when your website is built. This means that when you build your website in debug mode, the website will contain your debug web.config, while  and building your website with a production Solution Configuration will create your website with your production web.config.

In this tutorial we will create a new Solution Configuration called production which we will then use from Continua when we are deploying our website.

...

In your ContinuaDeployTutorial website, open up the configuration manager and select <New...> from the Active solution configuration dropdown (as shown in the images below).

Clicking <New...> will open up the New Solution Configuration dialog. This dialog allows us to create a new Solution Configuration which we can use when deploying to our production server. Lets call our new Solution Configuration Production and lets copy the settings from our existing Debug Solution Debug Solution Configuration and make sure that Create new project configurations is checked. (as shown below). 

Once our Production Solution Configuration has been saved, you should now see it appear in the Solution Configuration dropdown.

...

This will add a new production config transform called Web.Production.config (as shown below). This command actually creates a new config transform for each Solution Configuration that exists within your project.

Modifying the Web.Config and Working with Web.Config Transforms

Even though we now have 3 separate Web.Config transform files, there is still only one main config file that will need to be maintained during development. The main Web.Config file still contains all the config information for your web app, however these Web.Config transforms are used to change certain values depending on which Solution Configuration is being used at run time. It is important to note that the main Web.Config file should be configured to work on your local development machine. Any changes that occur through our Web.Config transforms will only occur when we publish our web app. So options like connection strings should point to your local development databases and any other appSettings should also point to locations on your local development machine.

...

Now that we have defined a connectionString that points to our local db, lets add a connectionString transform to our Web.Production.config. The entire Web.Production.config file should look like this:

...

When publishing your web app, set the publish method to File System and set a target location to the directory where the web app should be published (as shown below). 

...