I work as a web developer, primarily in C# (.Net). In my current position, I get to work on many different projects, and using a few different tools to help us get our job done.
One such tool we use is called Slow Cheetah. Basically, Slow Cheetah can allow you to add transforms for your config files based on the build configurations within Visual Studio. Your main config file will have all your base settings, and you can add different settings for certain sections, such as for a database server connection string that is different in development vs production. I came across an issue in one project I was working on that was not transforming my configurations for one part of my solution.
The project was a web application with a WCF service using Entity Framework to allow the website to talk to the database (there’s a bit more to the project, but that’s all you really need to know). So in my Visual Studio solution, there are several different Project files. The two important ones, lets call them Host and Web, are both using Slow Cheetah to transform the config settings for Debug, UAT and Production builds.
Now my Web project was working just fine, however the Host project’s app.config, and connectionStrings.config were not being transformed. In Visual Studio, you can right-click on a config file and “Preview Tranform”, and this was working as expected. After much trial and error, and a few google searches, I found that my .csproj file for the Host project had a slightly different order for the Slow Cheetah settings than the Web project.
It turns out, for the Slow Cheetah settings in a .csproj file, this:
<propertygroup label="SlowCheetah"> <slowcheetahtoolspath>$([System.IO.Path]::GetFullPath( $(MSBuildProjectDirectory)\..\packages\SlowCheetah.22.214.171.124\tools\))</slowcheetahtoolspath> <slowcheetah_enableimportfromnuget condition=" '$(SC_EnableImportFromNuGet)'=='' ">true</slowcheetah_enableimportfromnuget> <slowcheetah_nugetimportpath condition=" '$(SlowCheetah_NuGetImportPath)'=='' ">$([System.IO.Path]::GetFullPath( $(MSBuildProjectDirectory)\Properties\SlowCheetah\SlowCheetah.Transforms.targets ))</slowcheetah_nugetimportpath> <slowcheetahtargets condition=" '$(SlowCheetah_EnableImportFromNuGet)'=='true' and Exists('$(SlowCheetah_NuGetImportPath)') ">$(SlowCheetah_NuGetImportPath)</slowcheetahtargets> </propertygroup>
needs to be above this:
<import project="$(SlowCheetahTargets)" condition="Exists('$(SlowCheetahTargets)')" label="SlowCheetah"></import>
Then the transforms were working as normal.