Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Web.Config Transformations with Web Setup Project - Visual Studio

RSS
Modified on Fri, Apr 27, 2012, 10:17 AM by Administrator Categorized as Visual Studio and Developer Tools

Overview

Web Setup Projects don't normally apply web.config transformations properly. Instead, it simply copies the web.config file(s) as content files. This article details a workaround.

This article was adapted from http://stackoverflow.com/questions/2992778/asp-net-web-config-transformation-wont-work-in-installer.

Solution

1. Create the needed web.config transformation files (e.g., web.Debug.config, web.Release.config, etc.).

2. Manually edit web application project file (.CSPROJ file), adding the following code near the end. (You should see comments near the end of the file regarding this.)

<Target Name="AfterBuild">
  <TransformXml Source="Web.config" Transform="$(ProjectConfigTransformFileName)" Destination="Web.Transformed.config" />
</Target>

3. In the web setup project, select Content files > Exclude filter > add web.config and each web.*.config file.

4. In the web setup project, select File System > Web Application folder > Add file > select web.Transformed.config in the root of your web application project folder

5. In the same screen, rename web.transformed.config to web.config.

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.