31

I have a project I am trying to use SlowCheetah for. I have created my config file (Test.web.config) and all the transformations I want to use (Debug_Mock.config, Debug_SQL.config, Release) in my Build configuration I have a post-build event is supposed to copy the transformed file into another directory but the file cannot be found

(error xcopy exited with code 4)

SlowCheetah doesn't seem to be transforming the file and placing it in the output directory (bin folder) like I would expect. Does anyone have any ideas as to why it is not happening, maybe a setting somewhere?

FYI: This process works on another machine, with the same project. As far as I can tell the same set up as well. But I may not be looking in the correct place.

Agnel Amodia
  • 765
  • 8
  • 18
Richard S.
  • 713
  • 1
  • 9
  • 24
  • 2
    non of the solutions below worked for me :( did u get it to work in the end? – Ruslan Jun 01 '16 at 00:01
  • 1
    None of the below solutions worked for me too. The changes did not appear even in the preview for me. – NLV Nov 29 '16 at 19:38

8 Answers8

33

For me I found the issue was that the slow cheetah property group in the config file was below the section where it checked if it existed.

So the fix was simply to move the property group above that line somewhere which would allow the transform to run as expected.

Put this:

<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>

Above this:

<Import Project="$(SlowCheetahTargets)" Condition="Exists('$(SlowCheetahTargets)')" Label="SlowCheetah" />
laurencee
  • 818
  • 1
  • 7
  • 15
  • This fixed it for me; I'm using SlowCheetah 2.5.10.3 via NuGet, and my App.config file was not being transformed. I swapped the order of the two elements above and it started working. – Nick Jones Dec 17 '13 at 14:46
  • Having fixed this locally as above, builds started failing on our Jenkins build server as others have noted here: https://github.com/sayedihashimi/slow-cheetah/issues/114. The fix was to adjust the version of SlowCheetah in SlowCheetah.transforms.targets to the correct 2.5.10.3 version. – Nick Jones Dec 17 '13 at 15:56
  • This fixed it for me. I am using SlowCheetah 2.5.14 – Jason Boyd Dec 29 '14 at 21:39
  • This fixed it for me. Neither the PropertyGroup nor the Import had been added to my project's vbproj file. Additionally I did update the version number in the SlowCheetahToolsPath element – gillonba Sep 23 '15 at 16:14
  • what property group in whatg config file?? – Toolkit Apr 20 '16 at 12:22
  • 2
    @Toolkit the csproj/project file that you added SlowCheetah to – laurencee Apr 20 '16 at 23:56
16

Check in your Project, if there exists a folder named SlowCheetah containing the file SlowCheetah.Transforms.targets. If this file is missing, try the following steps:

  1. right click on solution
  2. "Manage NuGet Packages for Solution...", browse for SlowCheetah
  3. click on "Manage"
  4. deselect your project and click "Ok"
  5. click on "Manage" again
  6. select your project and click once more "Ok"

This will recreate the missing file.

Thorsten Hüglin
  • 1,217
  • 10
  • 11
  • This was it for me. I installed from http://visualstudiogallery.msdn.microsoft.com/69023d00-a4f9-4a34-a6cd-7e854ba318b5 which didn't create the folder. So I got Add/Preview but the transform wouldn't actually happen –  Jan 20 '14 at 16:08
  • 4
    _SlowCheetah_ folder is created under _Properties_ folder. – YuMei Sep 18 '14 at 19:50
  • this works for me, things turns out that we just install vs plugin, forget to install nuget package.Thanks Thorsten – ChengWhyNot Jul 23 '16 at 04:19
11
  • Enable build verbosity (Tools -> Options -> Projects and Solutions -> Build and Run) and see the difference between the version that is working and the one that is not.

  • To my knowledge, slow-Cheetah supports config transforms for the app.config files but not web.configs on debug at present. It should put a transformed web.config file in the bin folder of your project but your project still reads from the config file in the root folder. Please have a look at pre/post build events at http://sedodream.com/CommentView,guid,68b7e248-b9f5-4d07-bdfe-eb037bcf2cbb.aspx.

  • You can request for web config transform support on debug at
    https://github.com/sayedihashimi/slow-cheetah/issues/39

  • Try re-installing Slow-Cheetah.

user1858286
  • 164
  • 1
  • 5
  • 2
    This is marked as answered, but which step(s) fixed the problem? – Travis Parks Oct 07 '13 at 18:38
  • 5
    @TravisParks For me, I had installed SlowCheetah from http://visualstudiogallery.msdn.microsoft.com/69023d00-a4f9-4a34-a6cd-7e854ba318b5 which let me do the Add Transform and Preview Transform, but wouldn't change the output config. Then I installed SlowCheetah from nuget and it worked. –  Jan 20 '14 at 16:03
  • 2
    @ChrisCameron just installed SlowCheetah on VS2013 Up5 from the website. Preview works but it won't be transform while building. Installing from Nuget fixes that. Thanks! – Esselans Apr 06 '16 at 14:28
  • 1
    Thanks. Wasted many hours. Finally, uninstalling the extension and installing from nuget fixed it! – Gautam Jain Nov 23 '16 at 11:04
  • take a look at the csproj/vsproj answer below, this answer did not fix my problem, but adding the propertygroup did – Nathan Tregillus Apr 25 '17 at 16:20
7

Please Note, you have to install the SlowCheetah Visual studio extension AND the SlowCheetah nuget package for the project in question for the transformation to work.

BeHappy
  • 138
  • 2
  • 17
Frank Liu
  • 1,466
  • 3
  • 23
  • 36
6

After a reinstall as described above, I needed to add the subType and transformOnBuild nodes to my csproj file, and it started working for me.

<None Include="App.config">
  <SubType>Designer</SubType>
  <TransformOnBuild>true</TransformOnBuild>
</None> 
<None Include="App.QA.config">
  <DependentUpon>App.config</DependentUpon>
  <IsTransformFile>True</IsTransformFile>
</None>
fiat
  • 15,501
  • 9
  • 81
  • 103
Hink
  • 504
  • 8
  • 11
3

With SlowCheetah 2.5.15 and Visual Studio 2015, I had to uninstall the nuget package and then manually remove the following from the relevant .csproj file:

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

and

<PropertyGroup Label="SlowCheetah">
  <SlowCheetahToolsPath>$([System.IO.Path]::GetFullPath( $(MSBuildProjectDirectory)\..\packages\SlowCheetah.2.5.15\tools\))</SlowCheetahToolsPath>
  <SlowCheetah_EnableImportFromNuGet Condition=" '$(SlowCheetah_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>

Once this was done and the SlowCheetah nuget package was reinstalled, my problem was resolved.

James Blake
  • 1,050
  • 1
  • 14
  • 17
3

SlowCheetah 3.2.20 added a, uhh, "feature", designed to respect the "Do Not Copy" file setting in Visual Studio. So if you don't have your .config file set to "Copy Always" or "Copy if Newer", it won't copy them to the output folder.

See https://github.com/Microsoft/slow-cheetah/issues/182 for some details.

This was my issue - spent three hours debugging it...

Ken Smith
  • 20,305
  • 15
  • 100
  • 147
0

For me, the App.config transformation WAS working. Just that the output is not App.config. It's actually appname.exe.config. In fact I turned off the copying of app.config to the app build output folder, so as not to confuse others. The appname.exe executable picks up the configurations from appname.exe.config.

gurunara5
  • 1
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Luciana Oliveira Dec 16 '22 at 19:17