Automated Slow Cheetah Build methods
Asked Answered
S

4

9

I don't want to install Slow Cheetah on all the build servers.

We are using Slow Cheetah for config transformations and it is working perfectly fine. It generates multiple app.config files and we make changes to them as desired.

We have setup several servers. All of them has their code repositories, they pull the code from command line and build the packages accordingly. Those codes has those config files in it. But still when we compile the application from command line, packages are not generated with the transformation if slow cheetah is not installed on them. Otherwise it works fine.

We never know when we setup a new server and a new user, so it is not possible to install Slow cheetah on every one of them

It is possible somehow to use slow cheetah dll in the application and call the transform method manually from it?

Thanks

Shatter answered 1/10, 2012 at 10:16 Comment(1)
You mention building several app.config-files - might that be what I'm looking for over at #12670998 ? :-)Saliva
S
18

Detailed step by step process defined here

http://sedodream.com/2011/12/12/SlowCheetahXMLTransformsFromACIServer.aspx

Thanks

Shatter answered 1/10, 2012 at 11:4 Comment(1)
As a note for the link, I had to add Microsoft.Web.XmlTransform.dll also.Lymn
B
10

As an alternative to SlowCheetah, it's possible to handle this functionality by editing your project files manually. It's a little more cumbersome to set up, but it does mean that you have no extra DLLs required.

Open your project file in a text editor. At the bottom of the project file, just before the closing tag, include the following:

<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="AfterCompile" Condition="exists('app.$(Configuration).config')">
    <!-- Generate transformed app config in the intermediate directory -->
    <TransformXml Source="app.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="app.$(Configuration).config" />
    <!-- Force build process to use the transformed configuration file from now on. -->
    <ItemGroup>
        <AppConfigWithTargetPath Remove="app.config" />
        <AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config">
            <TargetPath>$(TargetFileName).config</TargetPath>
        </AppConfigWithTargetPath>
    </ItemGroup>
</Target>

Then, find in your project file the line and replace it with the following:

<ItemGroup>
    <Content Include="App.config" />
    <Content Include="App.Debug.config">
        <DependentUpon>App.config</DependentUpon>
    </Content>
    <Content Include="App.Release.config">
        <DependentUpon>App.config</DependentUpon>
    </Content>
</ItemGroup>

You’ll need to add an extra Content Include for each configuration you add – unfortunately with this method you don’t get the straightforward “add transforms” context menu.

After that it’s a case of creating the files in your project directory, and then you’re ready to go. It’s not as slick as SlowCheetah, but it does keep your code portable.

Bonaventura answered 1/10, 2012 at 10:49 Comment(5)
Actually plugging the Microsoft.Web.Publishing.Tasks.dll as task mean that you have to have visual studio installed on build server. This Dll shipped only with visual studio, not with .NET framework itself. So your statement about "no extra DLLs required" is incorrect. NB: As far as I understand - slowcheetah was created exact to solve this limitation - there was concrete task to transform configs\XML, but devs were not allowed to use it except with Visual Studio. I doubt Sayed Ibrahim Hashimi started slowcheetah cause he didn't know about TransformXml task.Uniparous
How do regular web projects compile with config transforms on a build machine if that .dll is not present? (I admit I am somewhat ignorant on this; I've always had VS installed on a build machine.) I think SlowCheetah was started to simplify the process - certainly the process I describe above is more cumbersome.Bonaventura
did they? AFAIK - project compiles but no transformation applied. And yes, this is the reason why all our build agents have VS installed. Actually there is no siginficant difference between what VS do with web.config transformations and what SlowCheetah. Correct me if I'm wrong, but VS just have locked this feature for web.configs, and it actually applicable to any kind of xml file. I used this task to transform not only azure ServiceDefinition and ServiceConfiguration,but to generate build-time transformation to run azure emulator instance on shared test server - painfull but achievable taskUniparous
The transforms in web projects and SlowCheetah are essentially the same. Yes I knew about TransformXml, I own it :) XDT can be used for any XML file, the web projects just have specific support for web.config. With SlowCheetah you don't need to install web projects.Wooton
Not working for me,. Hi could you please share me the sample working project because when I do the same in my proj file and publish the package (myweb.zip) then my app.config file is not converted!!Ankylose
D
5

The most recent version of SlowCheetah (2.5.14) is available on Nuget. When adding via nuget it is stored in the packages folder in the local solution directory (like all nuget packages) which means it should work on any build server out of the box now.

Demonstrator answered 7/11, 2014 at 22:42 Comment(0)
S
4

I include SlowCheetah in the application like the following, to avoid having it installed on the servers that build the solution:

  1. In my solution root, I have a folder Tools which contain (among other things) SlowCheetah
    1. myProject/Tools/SlowCheetah/SlowCheetah.Tasks.dll
    2. myProject/Tools/SlowCheetah/SlowCheetah.Transforms.targets
  2. In the (web-) application project's .csproj-file, i have this:

  <PropertyGroup>
          <SlowCheetahTargets Condition=" '$(SlowCheetahTargets)'=='' ">$(MSBuildProjectDirectory)\..\Tools\SlowCheetah\SlowCheetah.Transforms.targets  </SlowCheetahTargets>
   </PropertyGroup>

and this:

<Import Project="$(SlowCheetahTargets)" Condition="Exists('$(SlowCheetahTargets)')" />

..and it seems to handle the job very fine, even when building/publishing from TeamCity.

Edit:

You will find the two files mentioned in %localappdata%\Microsoft\MSBuild\SlowCheetah\v1 (drive:\Users\yourusername\AppData\Local\Microsoft\MSBuild\SlowCheetah\v1) when you have installed SlowCheetah into Visual Studio.

Saliva answered 1/10, 2012 at 10:35 Comment(1)
What would be the SlowCheetah.Transforms.Targets, kindly guide me. ThanksShatter

© 2022 - 2024 — McMap. All rights reserved.