Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

web.config transforms not being applied on either publish or build installation package

Today I started playing with the web.config transforms in VS 2010. To begin with, I attempted the same hello world example that features in a lot of the blog posts on this topic - updating a connection string.

I created the minimal example shown below (and similar to the one found in this blog). The problem is that whenever I do a right-click -> "Publish", or a right-click -> "Build Deployment Package" on the .csproj file, I'm not getting the correct output. Rather than a transformed web.config, I'm getting no web.config, and instead the two transform files are included.

What am I doing wrong? Any help gratefully received!

Web.config:

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <connectionStrings>
    <add name="ConnectionString" 
    connectionString="server=(local); initial catalog=myDB; 
    user=xxxx;password=xxxx" providerName="System.Data.SqlClient"/>
  </connectionStrings>
</configuration>

Web.debug.config:

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <connectionStrings>
    <add name="ConnectionString"
      connectionString="server=DebugServer; initial catalog=myDB; 
      user=xxxx;password=xxxx"
      providerName="System.Data.SqlClient"
      xdt:Transform="SetAttributes"
      xdt:Locator="Match(name)"/>
  </connectionStrings>
</configuration>

Web.release.config:

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <connectionStrings>
    <add name="ConnectionString"
      connectionString="server=ReleaseServer; initial catalog=myDB; 
      user=xxxx;password=xxxx"
      providerName="System.Data.SqlClient"
      xdt:Transform="SetAttributes"
      xdt:Locator="Match(name)"/>
  </connectionStrings>
</configuration>
like image 488
BenA Avatar asked Jun 16 '10 14:06

BenA


1 Answers

I had a similar problem, and the fix was because I had Solution Configurations set up for my environments, but I had never created project configurations that align to solution configurations.

To Check:

  1. Under "Build" --> "Solution Configuration"
  2. Change your "Active solution configuration", and make sure your project configurations line up according to the config files you've named.
like image 168
raterus Avatar answered Sep 26 '22 15:09

raterus