- | rssFeed | My book on MSBuild and Team Build | Archives and Categories Friday, January 04, 2013

SlowCheetah support for Azure Worker Roles

I have had a number of request to get SlowCheetah working for Azure Worker Roles. I think I have it working now. I have not yet released the support to the download page yet but after the support is verified I will update the release.

If you would like to try out a build which has support to transform app.config, as well as other XML files, for Azure Worker Roles you can find the VSIX at https://dl.dropbox.com/u/40134810/SlowCheetah/issue-44/SlowCheetah-issue-44.zip. After installing for worker role projects you can create XML transforms for app.config, and any other XML file. When you publish to azure, or create a package your files should be transformed.

More info on this on the following issues.

BTW if you are interested in my upcoming MSBuild book checkout msbuildbook.com

Sayed Ibrahim Hashimi @SayedIHashimi

azure | SlowCheetah Friday, January 04, 2013 8:14:45 AM (GMT Standard Time, UTC+00:00)  #     | 
Monday, December 24, 2012

SlowCheetah build server support updated

A while back I blogged about how to setup SlowCheetah on a Build server. The solution was good but it was a bit unwieldy and error prone, especially those who are not comfortable with MSBuild (this solution still works and is still a good approach for some scenarios). I’ve made this much easier, but wasn’t able to make it as easy as what I wanted. The solution that I choose is using NuGet. Ideally you’d be able to install the SlowCheetah NuGet package into a project, enable package restore and the check in your code. Unfortunately due to how NuGet package restore is implemented this flow is not currently possible. Hopefully in the near future Nuget will better support these scenarios. For now we will have to work with the solution below.

Background

The transformations are executed when your project is built. The way that this works is that when you use the SlowCheetah VS add-in to enable transformations, your project file is modified to import an additional MSBuild .targets file which knows how to do the transformations. This .targets file is placed in your %localappdata% folder. When you add the SlowCheetah NuGet package to your project, the .targets file (and supporting files) are downloaded to the packages folder. Your project is also modified to look at the packages folder for the .targets file which is imported.

For build server scenarios, when using NuGet for this it’s a bit of a chicken and egg problem. Let me clarify, we are using NuGet to update the build process for your project. If a solution is using NuGet, you will need to enable NuGet Package Restore. This is what will enable your NuGet packages to be download during build.

Package Restore is implemented to restore NuGet packages for each project whenever it is built. This is accomplished by adding an Import into your project to NuGet.targets. This works beautiful for the majority of cases, but fails completely if you are trying to update the build process for a given project with NuGet. When the build for a project starts if the the imported .targets file do not exist on disk they are not imported. You can visualize this flow as.

image

We need to find a way to get the packages restored, before your project is built. We can achieve this by executing a build which will be used to simply restore our packages. Now let’s see how we can workaround this issue.

Solution

We need to find a way to restore the packages before the project is built. The easiest way to do this is to add a dummy solution to be built before your actual solution/project. Follow these steps.

1. Install the SlowCheetah NuGet package into the project using SlowCheetah.

You can do this by using the Package Manager Console, and executing the command Install-Package SlowCheetah –pre. Note: after the package is released you can remove the –pre.

2. Enable Package Restore for the solution

You can do this by right clicking on the solution and selecting Enable NuGet Package Restore.

3. Configure build server to build restorePackage.proj before your solution

As described we need a new solution that can be used to restore the required packages. When you install SlowCheetah it will automatically create a packageRestore.proj file in the root of your project. You can use this to easily restore your NuGet packages. All you need to do is to build this file before you build your solution or build script. If you are using Team Build this is pretty easy. Edit the build definition and then add packageRestore.proj to the Items to Build list. You can find this on the Process tab.

image

 

Make sure that packageRestore.proj is above (built before) your solution.

SNAGHTML158ea083

With these changes when the empty solution is built, it will restore the SlowCheetah .targets file. Then the target solution will be built, the .targets file will already be downloaded and your transforms will execute as needed.

I will work with the NuGet team to see if there is something better that can be done here. I will keep you all posted if there is any update.I would love if you tried out this new support and let me know if you have any issues with it.

Sayed Ibrahim Hashimi | @SayedIHashimi

SlowCheetah | Visual Studio 2010 | Visual Studio 2012 Monday, December 24, 2012 9:37:24 PM (GMT Standard Time, UTC+00:00)  #     | 
Thursday, August 16, 2012

SlowCheetah v2.4 Released

I jus released a new version of SlowCheetah, my Visual Studio extension which enables you to transform app.config, and other XML files, during F5 for non-web projects. In this update I added support for Visual Studio 2012 as well as the bug fixes below.
  1. Fix for Preview command doesn't show up for all web.config transforms
  2. Fix for XML transforms not working with Azure SDK
  3. Fix for XML transforms not working with Azure SDK
  4. Fix for .config files do no transform in VS 2012 RC
  5. Fix for In web project, project File gets modified while adding transformation
  6. Fix for Add Transform should not show up for .settings files
  7. Fix for Transforms should be added as None

If you are interested in the project you can take a look at the code at https://github.com/sayedihashimi/slow-cheetah and if you have any issues please file a bug at https://github.com/sayedihashimi/slow-cheetah/issues.

 

Thanks,
Sayed Ibrahim Hashimi | @SayedIHashimi

    SlowCheetah | Visual Studio | Visual Studio 11 | Visual Studio 2010 | Visual Studio 2012 Thursday, August 16, 2012 1:54:26 AM (GMT Daylight Time, UTC+01:00)  #     | 
    Thursday, May 24, 2012

    SlowCheetah updated

    image

    Wanted to let you know that I just released v2.3 of my Visual Studio extension SlowCheetah. If you are not familiar with SlowCheetah here is an intro. For client projects (i.e. non-web projects) it allows you to transform the app.config (or any XML file) on F5 (debug) or CTRL + F5, it also has a preview functionality which allows you to see the results of the transform quickly. For Web Projects it allows you to transform XML files during package/publish (and of course the preview functionality works in web projects too). The transform behavior is all in MSBuild targets/tasks so command line support is built in. It’s also easy to integrate SlowCheetah into CI servers.

    Below are the updates that we have in v2.3.

    Preview support in VS 11
    In the previous version we added support for VS 11 but the preview functionality didn’t work because the preview tool we used in VS 2010 didn’t exist in VS 11. VS 11 now has a new diffing tool and in this version we now support invoking this new service.

    ClickOnce related updates

    ClickOnce support was added in a previous version but the support was limited to app.config. In this version when you publish an application using ClickOnce if you have transforms in any other XML file defined those transforms will be applied and published.

    Setup projects updates
    Similar to ClickOnce the support for setup projects was limited to app.config only. In this version we now have support for all XML files not just app.config. There was also a bug in the previous version relating to setup projects. For setup projects if a file was being transformed from a linked file when you built the solution you would receive an error. We have fixed that bug.


    Sayed Ibrahim Hashimi @SayedIHashimi

    SlowCheetah Thursday, May 24, 2012 8:18:22 AM (GMT Daylight Time, UTC+01:00)  #     | 
    Friday, April 27, 2012

    SlowCheetah VS 11 support and now on github

    In case you are not familiar with SlowCheetah, it is a Visual Studio extension which allows you to transform app.config files in the same way that web.config files are. More info on the project page http://visualstudiogallery.msdn.microsoft.com/69023d00-a4f9-4a34-a6cd-7e854ba318b5.

    I wanted to let everyone know that I have updated SlowCheetah to support Visual Studio 11 and I have also placed the project on github at https://github.com/sayedihashimi/slow-cheetah. Regarding the VS 11 support there is one known issue that we currently do not support the preview functionality on VS 11. This is an item which we will be fixing for the next release.

     

    Thanks,
    Sayed Ibrahim Hashimi @SayedIHashimi

    Reminder: even though I work for Microsoft this is a personal project and not formally affiliated with Microsoft

    msbuild | SlowCheetah | Visual Studio 11 | Visual Studio 2010 Friday, April 27, 2012 7:52:02 PM (GMT Daylight Time, UTC+01:00)  #     | 
    Monday, December 12, 2011

    SlowCheetah XML transforms from a CI server

    Please read my updated post, the info below is no longer required for some scenarios SlowCheetah build server support updated

    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

    Install-Manifest.xml An XML file which describes the files that are installed. This is used by the plugin itself, you should never have to do anything with this file.
    SlowCheetah.Tasks.dll The assembly which contains the MSBuild task which transforms XML files.
    SlowCheetah.Transforms.targets The MSBuild file which enables XML file transformation

     

    The add-in adds the following menu command to any XML file for supported project types.

    image

    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.

    1. A new MSBuild property SlowCheetahTargets is added to the project and it points to the SlowCheetah.transforms.targets file in %localappdata%
    2. An import for that file is added

    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:

    1. Create a folder named SlowCheetah in the same folder as my solution
    2. Added SlowCheetah.Tasks.dll and SlowCheetah.Transforms.targets to that folder
    3. Create a solution folder named SlowCheetah in the solution
    4. Drag and drop the files from your SlowCheetah folder into the SolutionFolder
    5. Updated my project file to point to these files

    Now your solution should look roughly like the following image.

    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:

    1. Right click on the project and select unload
    2. Right click on the unloaded project and select Edit
    3. Update the value for the SlowCheetahTargets import

    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

    msbuild | SlowCheetah | Visual Studio | Visual Studio 2010 Monday, December 12, 2011 5:02:42 AM (GMT Standard Time, UTC+00:00)  #     |