Tuesday, September 4, 2012

Creating XML tranformations for all environment configs without deploying application

Edit project file and paste following code at the end of the file.

<Target Name="BeforeBuild">
    <MakeDir Directories="$(OutDir)TransformedConfigs" Condition="!Exists('$(OutDir)TransformedConfigs')"/>
    <TransformXml Source="Web.config" Transform="Web.Dev.config" Destination="$(OutDir)TransformedConfigs\Web.Dev.config" />
    <TransformXml Source="Web.config" Transform="Web.QA.config" Destination="$(OutDir)TransformedConfigs\Web.QA.config" />
    <TransformXml Source="Web.config" Transform="Web.UAT.config" Destination="$(OutDir)TransformedConfigs\Web.UAT.config" />
    <TransformXml Source="Web.config" Transform="Web.Prod.config" Destination="$(OutDir)TransformedConfigs\Web.Prod.config" />
</Target>


This will create TransformedConfigs folder inside bin of the project and will add all specified transformed configs.