This package enables you to transform your app.config or any other XML file based on the build configuration. It also adds additional tooling to help you create XML transforms.. Written by: Sayed Ibrahim Hashimi, Chuck England and Bill Hiebert
We had several self-inflicted wounds with accidentally testing applications that had config entries that pointed to production instead of the quality assurance environment. Because of this we searched and found Slow Cheetah that let us separate the configs into Development, QA, and Production. Things are a lot safer now. Thanks for creating this.
Watched the Visual Studio Toolbox video on this some time ago, but have only just installed it. The tool is great and Its saving me heaps of time! No more building and deploying just to diff config files. Thanks for the work on this extension!
That is a cool stuff. That is to be installed on a develoer computer (VS). But how can I install on build server? Do you have any installation program for that?
Hi Yuri, see my blog post at http://sedodream.com/2012/12/24/SlowCheetahBuildServerSupportUpdated.aspx regarding how to get it working for build servers.
It's on the backlog https://github.com/sayedihashimi/slow-cheetah/issues/39. Should be the next major feature I work on. For web projects this support is much trickier than non-web projects.
Excellent. My app.config's are now updated with a Test, PreProd or Prod SQL Server connection string, even when running (rather than Deploying) my apps. A lifesaver - thanks!
Awesome! I'm just so used to web.config transforms in ASP.Net applications that I also want this functionality in a WinForms Application.
Your add-in works like a charm. Keep up the good work. I hope this add-in will be included into VS 2012 sometime in the future, just like they did with Nuget.
Even debug sessions are effected by the transform, depending on the selecte d solution configuration! Really nice work.
It won't be included in VS2012, and at this time it likely wont ever make it into VS. If you think it should I suggest you make a suggestion at http://visualstudio.uservoice.com/ and have all your friends vote it up.
I have a Build Server, and every night it will automatically build the solution for 2 different configurations (Staging and Testing). It then publishes those, so the respective teams can test and explore the latest changes.
Is there anything I need to do so the Build Server transforms my config files correctly?
I have ConnectionStrings.config and two tranforms:
ConnectionStrings.Staging.config
ConnectionStrings.Snapshot.config
When I build the deployment package, the transforms are applied correctly. The problem is, all 3 files are included in the package instead of just a ConnectionStrings.config.
Hi Jason, I just replied back to the other thread that you are on here titled "ASP.NET publish leaves debug and release versions". Let's discuss this there.
Further details: I can create the transforms by right-clicking on the main .settings file, but when running the tests it always takes whatever connection strings are setup in the main .settings file rather than the .debug.settings file.
.settings files do not work with Transforms. We had a discussion here regarding those at http://visualstudiogallery.msdn.microsoft.com/69023d00-a4f9-4a34-a6cd-7e854ba318b5/view/Discussions/4#3944. The issue is that .settings files are converted to code so transforms won't work due to that.
FYI I have created an issue at https://github.com/sayedihashimi/slow-cheetah/issues/13 to modify the behavior to not show the Add Transform command for .settings files.
I haven't had time to try this yet (I don't have access to a machine with VS installed right now), are you saying that for Web projects in order to Preview the project file gets modified? That shouldn't be the case, if it is could you open an issue at https://github.com/sayedihashimi/slow-cheetah/issues so that we can track this?
Hey there! Got it installed and tested. The builds transform OK. However...
'Package...' to Windows Azure does not. I have two transforms on my app.config in my Windows Azure Worker role: 'Release' and 'ReleaseTest'. When I compile the two output folders contain each a separate version of my app.config (renamed to match my project naturally).
However when I select 'Package...' on my Windows Azure deployment project and get my packaged deployment the transform does not happen. I open up the packages and extract out my .config files and compare. In both cases they get the values from the app.config and the transformations have not been done.
Do you think this would be hard to fix? The scenario is I want to transform my app.config for the worker role to deploy different cache configurations on different deployments.
Hi Magnus, unfortunately we were not able to get support for Azure projects in this release. I am not sure what this would take, I need to investigate it a bit more.
This seems to work: http://wely-lau.net/2012/03/14/applying-config-transformation-app-config
In short, edit the csproj file for your worker role project and "Scroll down to the end of the file and add the following snippet before the closing tag of project:
<Import Project="$(CloudExtensionsDir)Microsoft.WindowsAzure.targets" />
<Target Name="CopyWorkerRoleConfigurations" BeforeTargets="AfterPackageComputeService">
<Copy SourceFiles="..WorkerRole1bin$(Configuration)WorkerRole1.dll.config"
DestinationFolder="$(IntermediateOutputPath)WorkerRole1" OverwriteReadOnlyFiles="true" />
</Target>
</Project>"
Thanks Jeff for the pointer. This seems to be covering app.config for Azure worker roles. It seems like we should also support transforming other files as well. I am going to go ahead and add this support.
Jeff could you email me at sayedha [at] (microsoftDOTcom) so that I can send you the package once I have it for testing?
Sayed, sorry for the long delay. Am I missing the setting on here to enable email notifications for replies? Anyway, email sent. Hopefully I'm not too late.
Hi Jeff, I have worked on this and may have something working. Can you checkout the discussion at https://github.com/sayedihashimi/slow-cheetah/issues/5#issuecomment-5972109 for more info and a link to download the bits? If you try it out please let me know what you find.
Perhaps I am missing something...when I Build my project in VS2010 I also copy the output to another location. However, the transforms have not taken place at this stage?
If check my bin/release folder, the transforms are there, but the VS Post Build Event has already copied my files?
Any advice?
Two things you should try:
1. Make sure the source file is not marked as Copy to output directory
2. Instead of a post build event create a target in your project file and set the attributes DependsOnTargets="TransformAllFiles" AfterTargets="Build"
We have a number of config files that require transformations across different projects in the same solution.
I've had the idea of creating a config project within the solution that contains the shared config files with their transformations then I would be able to add these config files as linked files into my other projects.
For example the ConnectionStrings node in web/app.config's can use a configSource property which points at the linked file leaving the transformations to be performed by the config project.
Has anyone don the same / can see any potential problems? I also intend to follow Sayed's blog article of integrating SlowCheetah into our solution with solution items so our build server can perfrom the transformations.
I haven't tried that scenario myself, but the latest published version does have support for transforming linked files. Let me know if you have any issues with the implementation.
Hi. I'm trying to use the same set up that Mike as described to allow a single config file to be shared with several projects, but I cannot get the linked file transformation working. The parent file is always transformed but the linked file isn't. Is there any extra configuration required to transform linked files?
Same here. My app.config transforms fine but the linked file is not transforming.
Preview Transform in the UI shows the transform however it doesn't modify the file in bin\debug after a build.
Running latest build of Slow Cheetah.
@Phil/CodeJocky, there may be a bug here, I thought this was working. Can one of you guys send me a sample solution so that I could take a look at this? My email is sayedha [at]{MicrosoftDOTcom}.
Oops. Apologies Sayed. I think this is PEBCAK.
I just realised that being a linked file it defaulted to a None build action.
Setting the config file properties to Content/Copy Always has fixed it.
UPDATE: Setting the config file properties to Content/*Copy if newer* has fixed it.
Make sure you don't use *Copy Always* otherwise the transform gets overwritten with the original.
I'm probably doing something wrong, but I have an AfterBuild target in my project that copies output files to another directory:
<Target Name="AfterBuild">
<ItemGroup>
<FilesToCopy Include="$(OutputPath)**\*.*" />
</ItemGroup>
<Copy SourceFiles="@(FilesToCopy)" DestinationFolder="..\..\FitNesse\dll_repository\%(RecursiveDir)" />
</Target>
However, it would appear that SlowCheetah is actually running the transforms *after* that operation. The result is I get copies of the pre-transformed configs :(
Is there something else I should be doing?
@jw_carroll You should get a copy of my MSBuild book http://www.amazon.com/gp/product/0735645248?ie=UTF8&tag=sedodream-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=0735645248.
I would like to leverage the technology here to facilitate transformations when installing NuGet Packages. I think the way to do it will be to have a special "exe" that you include in your NuGet Package that is executed by PowerShell once the NuGet is installed. It can be passed various parameters to identify the files to be merged/transformed but missing is the technology to execute the transform outside a build environment.
Any chance you can help there?