Search code examples
azuremsbuildslowcheetah

SlowCheetah Azure web role not transformed


I am using SlowCheetah 2.5.10.6 in my Visual Studio 2013 solution in which I want to create a web role package for deployment. I am using Azure Tools 2.3. My default web.config transforms are working correctly. However, the SlowCheetah transforms do not work. Somehow this should be working: Slow Cheetah issue 5 In my output window I see the following:

1>Task "SlowCheetah.Xdt.TransformXml"
1>  Transfroming source file: D:\web\Project\src\Project.Web\App_Config\OTAP\connectionStrings.config
1>  Applying Transform File: App_Config\OTAP\connectionStrings.O.config
1>  Output File: bin\App_Config\OTAP\connectionStrings.config
1>Done executing task "SlowCheetah.Xdt.TransformXml".

In my bin folder I see the correctly transformed file.

I also see the following line in my output:

3>  Task "Message"
3>      TransformedWebFiles = App_Config\OTAP\connectionStrings.config, DestinationRelativePath=App_Config\OTAP\connectionStrings.config, Exclude=False, FromTarget=CollectFilesFromContent, Category=Run, ProjectFileType=Default

But when the package is created, the original file is used

3>Target "CopyWebRoleFiles" in file "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Windows Azure Tools\2.3\Microsoft.WindowsAzure.targets" from project "D:\web\Project\src\Project\Project.ccproj" (target "CopyRoleFiles" depends on it):
3>  Task "Message"
3>      CurrentRoleWebFiles=D:\web\Project\src\Project.Web\App_Config\OTAP\appSettings.config -> App_Config\OTAP\appSettings.config
3>  Task "Message"
3>      CurrentRoleWebFiles=D:\web\Project\src\Project.Web\App_Config\OTAP\connectionStrings.config -> App_Config\OTAP\connectionStrings.config

So my base config is used in the package and I want connectionStrings.*.config to be used. Does anybody know what I am doing wrong here?


Solution

  • I fixed the problem with the following MSBuild script:

    <Target Name="DeploySlowCheetahTransforms" AfterTargets="CopyWebRoleFiles" Condition="'@(WebRoleReferences)' != ''">
        <PropertyGroup>
          <IntermediateWebOutputPath>%(WebRoleReferences.OutputDir)</IntermediateWebOutputPath>
        </PropertyGroup>
        <ItemGroup>
            <TransformedFiles Include="$(WebTargetDir)\**\*.config" Exclude="$(WebTargetDir)\**\*.dll.config;$(WebTargetDir)\**\web*.config" />
        </ItemGroup>
        <Copy SourceFiles="@(TransformedFiles)" DestinationFiles="@(TransformedFiles->'$(IntermediateWebOutputPath)\%(RecursiveDir)%(Filename)%(Extension)')" />
    </Target>
    

    This scripts needs to be added to the ccproj file. The WebRoleReferences and WebTargetDir variables are created in Microsoft.WindowsAzure.targets. This script gets all the transformed config files from the OutputPath of your csproj file and copies them to the OutputDir which is used to create the Azure WebRole package.