Question

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

Was it helpful?

Solution

Detailed step by step process defined here

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

Thanks

OTHER TIPS

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.

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top