Search code examples
azureslowcheetah

Transform external config in a web role


Can slowcheetah transform an external config file in an azure web role? e.g. I have logging info in log4net.config. But the transformed version does not get created when packaged.


Solution

  • I did not manage to get slowCheetah working in my Azure solution. One alternative you can use is to create complete config files for each environment - e.g. :

    • log4net.debug.config
    • log4net.release.config

    and copy the contents of these into the log4net.config at buildtime depending on the build configuration chosen.

    This is done by adding a build target to your csproj file like so:

    <Target Name="BeforeBuild">
      <Delete Files="$(ProjectDir)log4net.config" />
      <Copy SourceFiles="$(ProjectDir)log4net.$(Configuration).config" 
                         DestinationFiles="$(ProjectDir)log4net.config" />
    </Target>
    

    (you may have to modify the paths in the script depending on where in the solution your config files are)

    You can find more information on MSBuild and manipulating your .csproj file here and here