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>
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With