A few months ago I published a Visual Studio add-in, SlowCheetah – XML Transforms, which enables you to transform any XML file during a build in the same way that you can transform the web.config during publish/package for web projects. Since then I’ve received numerous requests to demonstrate how the transforms can be kicked in from a CI server. It’s actually pretty easy because all the logic from a transform perspective is contained inside of MSBuild tasks/targets. The Visual Studio add-in itself is only delivering the support for gestures/preview.
Before I dive into how to enable this for a CI server let me explain how the plugin works and then the CI integration will be come much clearer. When you load a project/solution in Visual Studio for the first time after you installed SlowCheetah a set of files will be written to %localappdata%\Microsoft\MSBuild\SlowCheetah\v1. Those file are:
Name
Description
The add-in adds the following menu command to any XML file for supported project types.
When you click on this for the first time the add-in needs to make some changes to your project file so you are prompted to accept that. After you do the following changes are applied to your project file.
More specifically the elements added to your project file are.
<PropertyGroup> <SlowCheetahTargets Condition=" '$(SlowCheetahTargets)'=='' ">$(LOCALAPPDATA)\Microsoft\MSBuild\SlowCheetah\v1\SlowCheetah.Transforms.targets</SlowCheetahTargets> </PropertyGroup> <Import Project="$(SlowCheetahTargets)" Condition="Exists('$(SlowCheetahTargets)')" />
Note: If you look at your project file they will not be next to each other. The property will be towards the top of the project file and the import towards the bottom.
So now you might have an idea of why this won’t work on your CI server, the file SlowCheetah.Transforms.targets will not exist in the %localappdata% folder. There is an easy to way to fix this which doesn’t require any changes to your CI server. Check in the files and update your import. Here is what I did:
Now your solution should look roughly like the following image.
Note: Steps #3/#4 are not strictly required
For #5 you’ll have to edit your project file, don’t worry its an easy modification. Just follow these steps:
In my case the folder that I placed the files into is 1 directory above the project itself. So the new value for the property is as follows.
<SlowCheetahTargets>$(MSBuildProjectDirectory)\..\SlowCheetah\SlowCheetah.Transforms.targets</SlowCheetahTargets>
After that I checked in all the files, kicked off a build and viola the files are transformed. Let me know if you need any more info.
Sayed Ibrahim Hashimi – @SayedIHashimi
Note: I work for Microsoft, but these are my own opinions
Remember Me
a@href@title, b, blockquote@cite, strike, strong, sub
Theme design by Jelle Druyts
Powered by: newtelligence dasBlog 2.3.9074.18820
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2012, Sayed Ibrahim Hashimi
E-mail