SlowCheetah not transforming file on build

2019-03-10 18:12发布

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.

7条回答
\"骚年 ilove
2楼-- · 2019-03-10 18:55

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

查看更多
再贱就再见
3楼-- · 2019-03-10 18:58

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.

查看更多
欢心
4楼-- · 2019-03-10 19:01

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.

查看更多
▲ chillily
5楼-- · 2019-03-10 19:05

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" />
查看更多
Deceive 欺骗
6楼-- · 2019-03-10 19:05

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.

查看更多
Viruses.
7楼-- · 2019-03-10 19:10

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>
查看更多
登录 后发表回答