a developer's notes – a semi-technical web development BLOG

July 15, 2013

Using Visual Studio 2012 Web.config Transform

Filed under: ASP.NET — Duy Nguyen @ 12:15 pm

1. Open Configuration Manager

ConfigurationManager

2. Add a new configuration

CreateConfig

3. Add a new Config Transform

AddConfigTransform

You will now see the newly added config file.

AddedTransform

4. Modify the config file and add in sections of code that will be replaced with new configurations from your new environment. Highlighted in yellow, I have added a new connection string for the devlocal environment.

ModifyConfig

5. When you Publish or deploy your project, in the generated .zip file, the web.config will look like this… GeneratedWebConfig
When you deploy the application, the replaceable tokens will be replace by values in your “parameters.xml” file. If you don’t want this behavior and want the generated web.config file to contain the actual values, you can modify your .csproj file and add this

under the PropertyGroup section.

<AutoParameterizationWebConfigConnectionStrings>False</AutoParameterizationWebConfigConnectionStrings>

example:
AutoParameterizationOff

You can read more about this at http://msdn.microsoft.com/en-us/library/dd465318%28v=vs.100%29.aspx

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: