Monday, August 20, 2012

Automated web config transformation for Uhuru AppCloud

I use the Uhuru AppCloud ( hosting some of my applications. It's an excellent resource for serving your apps from the cloud. 

For .NET applications, they provide the Uhuru Cloud Manager plugin for Visual Studio that makes deployment simple. The one piece of configuration that is required by the developer is to change the Web.config's database references to point to their new locations in the cloud. I wanted to automate this bit of configuration using Visual Studio tools. 

Visual Studio uses it's Configuration Manager to implement multiple deployment environments when deploying, but its intended to be used with the VS One-Click publishing  tool, rather than the Cloud Manager plugin. 

Here’s a way to use the standalone Web Configuration Transformation Tool to perform the same transform that Visual Studio’s Configuration Manager uses to implement multiple deployment environments. This lets you keep store and your Uhuru configuration in the project for use when needed, while keeping your Default configuration file with its local settings for Debug mode testing. 

I. Use Visual Studio to create your transform template.
  1. In VS, choose Build > Configuration Manager > <New...> and name it UhuruCloud, for example.
  2. In Solution Explorer, right-click on your Web.Config file and choose 'Add Config Transforms'
  3. Edit the resulting Web.UhuruCloud.config for the transform. (See )
  4. For example, my Web.config file contained this:

    <add name="ApplicationServices"
      connectionString="data source=localhost;Integrated Security=SSPI;"
      providerName="System.Data.SqlClient" />

    and the transform xsl I needed looked like this:

<configuration xmlns:xdt="">
        <add name="ApplicationServices"
          connectionString="{mssql-2008#SQL Server}"
          xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>

II. Using the standalone Config Transform standalone Tool.
  1. Get the tool from
  2. The syntax of the tool is like so:

ctt.exe s:source.config t:transform.config d:destination.config

That’s just the most basic usage. Other good Examples are provided in the distribution. For me, it was handy to have a quick batch script to make that call easier. Especially while trying to get the paths just right.

File: ctt_run.bat
@ECHO off
rem ...Set (S)ource, (T)emplate, and (D)estination files here
SET S=C:\Projects\MySolution\MyApp\Web.config
SET T=C:\ Projects \ MySolution \ MyApp \Web.UhuruCloud.config
SET D=Web.New.config
@ECHO on
ctt.exe s:%S% t:%T% d:%D%

That’s it. (My example wrote the transformed file 'Web.New.config'.) 

I also posted this at StackOverflow

And in UhuruCloud's forum

Put a git repository into DropBox

Not locked to GitHub anymore. Local repos on laptop and Mac pull from master on filesystem DropBox dir.

Friday, August 17, 2012

New Cygwin installs running

I have a decent install of Cygwin on the new desktop and laptop now. Got the terminal and shell how I like it. Console2.