When we work on a Sitecore build, a very common scenario is to allow each developer to develop against a local Sitecore instance with a database to develop against. If you are using tools like TDS then it's easy to share new configurations between development environments by checking files into source control
One part of this process that we can't escape is the requirement for each developer to have his/her own database connection strings, application settings checked in. As we work locally, using the standard build transforms in a deployment package won't work, however, we can add build tasks directly into the 'AfterBuild' build process directly from our .csproj file. In today's tutorial, I'm going to cover the steps needed to transform a simple connection string within the App_Config folder. This example is very basic and you will probably want to tinker with it for your individual needs.
<?xml version="1.0" encoding="utf-8"?>
<add name="core" connectionString="user id=dev;password=password;Data Source=DEV\.;Database=Sitecore_Core" />
<add name="master" connectionString="user id=dev;password=password;Data Source=DEV\;Database=Sitecore_Master" />
<add name="web" connectionString="user id=dev;password=password;Data Source=DEV\;Database=Sitecore_Web" />
<add name="analytics" connectionString="user id=dev;password=password;Data Source=DEV\;Database=Sitecore_Analytics" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Output TaskParameter="Lines" ItemName="TransformedConnectionStrings" />
<Output TaskParameter="Lines" ItemName="UnTransformedConnectionStrings" />
<Copy Condition=" @(TransformedConnectionStrings) != @(UnTransformedConnectionStrings)"
DestinationFiles="App_Config\ConnectionStrings.config" OverwriteReadOnlyFiles="True" />
Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge