3
votes

I am confused by the rapid pace and terrific work done by Sayed Hashimi and company on SlowCheetah, specifically whether or not SlowCheetah is able to transform files on Build instead of just Package and Publish.

I have SlowCheetah installed and am able to auto-generate the build configuration instances for app.config of a console application I am working with the development team to deploy. On build, a new "SlowCheetah" directory is created under the $(ProjectDir)\obj\x86\$(BuildConfig) directory. The obj\x86\STAGE\SlowCheetah directory, for instance, contains an app.config file with the transform completed as indicated when right clicking the STAGE transform and selecting "View Transforms".

The \bin\$(BuildConfig) directory, however, contains the untransformed app.config file as well as all of the templates for each of the $(BuildConfig) transformations - instead of replacing the app.config file in the bin\x86\STAGE directory with the one from SlowCheetah.

The build completes without error.

Is this the expected action, or is something still not working correctly?

@sayed-ibrahim-hashimi Each $(Configuration) has a transform. The transforms displays properly when viewing in Visual Studio, and is properly transformed in the \slowcheetah directory under the \obj directory tree. Examples of transforms are:

<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform
<connectionStrings>
<add name="Portal" connectionString="Data Source=transformtestserver.domain.local;Initial Catalog=TestDB;User Id=TestUser;Password=testpw1;" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
<add name="DictionaryDatabase" connectionString="Data Source=transformtestserver.domain.local;Initial Catalog=TestDB;User Id=TestUser;Password=testpw2;" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
<add name="LoggingDatabase" connectionString="Data Source=transformtestserver.domain.local;Initial Catalog=TestDB;User Id=TestUser;Password=testpw3;" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>    
</connectionStrings>
</configuration>

The problem may be related to the Nuget/solution configuration. The project I am working with is one part of a very large solution. I had a difficult time getting SlowCheetah installed and working - at one point finding Nuget said SlowCheetah was installed but the solution package directory did not contain SlowCheetah.

I setup a workaround in TeamCity to pickup the transformed app.config file from the \obj directory, but would really like to resolve the problem so I can rollout SC to the full development group. Is there a verbose log we can look at that might point out the details?

2
App.config should transform on build. Can you give more specific repro steps here? Can you try an Insert transform to see if the source file is being modified?Sayed Ibrahim Hashimi
The reply section does not provide enough room for a detailed answer, a detailed response to your question with an example transform is appended to the original post, beginning with @sayed-ibrahim-hashimiEHuggins
@stackoverflow.com/users/105999/sayed-ibrahim-hashimi I turned on diagnostic output in VS2010 and saw that app.config is being transformed and saved as application.exe.config - which does contain the correctly transformed web.$(Condition).config file. I looked up the details of exe.config files and see that this is the correct behavior for Windows executables. I was looking for an app.config file. Looks like I was wasting your time on this one - thank you for being responsive and writing awesome apps, and books. Your MSBUILD 2nd Ed. is used most every week for one reason or another.EHuggins
@EHuggins I'm having a very similar issue. Although I'm referencing additional config files within my App.config file; and I wish to transform the contents of these config files. Like you I'm seeing an output Application.exe.config, but this simply has the original link to the referenced config files within it, and the files themselves are not transformed in any way. Any ideas? Any suggestions much appreciated.WheretheresaWill

2 Answers

3
votes

I faced with the same problem.

Local compilation in VS works great, but on build Agent (TeamCity) the transformation magic not happend!

The solution I found relating to the location of the xml element in the proj file

  <PropertyGroup Label="SlowCheetah">
    <SlowCheetahToolsPath>$([System.IO.Path]::GetFullPath( $(MSBuildProjectDirectory)\..\packages\SlowCheetah.2.5.10.3\tools\))</SlowCheetahToolsPath>
    <SlowCheetah_EnableImportFromNuGet Condition=" '$(SC_EnableImportFromNuGet)'=='' ">true</SlowCheetah_EnableImportFromNuGet>
    <SlowCheetah_NuGetImportPath Condition=" '$(SlowCheetah_NuGetImportPath)'=='' ">$([System.IO.Path]::GetFullPath( $(MSBuildProjectDirectory)\Properties\SlowCheetah\SlowCheetah.Transforms.targets ))</SlowCheetah_NuGetImportPath>
    <SlowCheetahTargets Condition=" '$(SlowCheetah_EnableImportFromNuGet)'=='true' and Exists('$(SlowCheetah_NuGetImportPath)') ">$(SlowCheetah_NuGetImportPath)</SlowCheetahTargets>
  </PropertyGroup>

I have noticed is that when the PropertyGroup is above all ItemGroup`s ellements MsBuild.exe at last did the Transformation

0
votes

Look for duplicate SlowCheetahTargets section - I had an older version and a newer version and the older one was pointing to a location that no longer existed in the nuget packages directory.

Delete the whole property group for the older / duplicated SlowCheetahTargets section and that should fix it.