30

我有一个项目正在尝试使用 SlowCheetah。我已经在构建配置中创建了我的配置文件 (Test.web.config) 和我想要使用的所有转换 (Debug_Mock.config、Debug_SQL.config、Release) 我有一个构建后事件应该复制转换后的文件进入另一个目录,但找不到该文件

(错误 xcopy 以代码 4 退出)

SlowCheetah 似乎没有像我预期的那样转换文件并将其放在输出目录(bin 文件夹)中。有没有人知道为什么它没有发生,也许是某个地方的设置?

仅供参考:此过程适用于具有相同项目的另一台机器。据我所知,同样的设置也是如此。但我可能没有找对地方。

4

7 回答 7

33

对我来说,我发现问题是配置文件中的慢 cheetah 属性组位于它检查是否存在的部分下方。

因此,修复只是将属性组移到该行上方的某个位置,以允许转换按预期运行。

把这个:

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

在此之上:

<Import Project="$(SlowCheetahTargets)" Condition="Exists('$(SlowCheetahTargets)')" Label="SlowCheetah" />
于 2013-11-24T20:46:12.877 回答
15

检查您的项目,如果存在名为SlowCheetah的文件夹,其中包含文件SlowCheetah.Transforms.targets。如果此文件丢失,请尝试以下步骤:

  1. 右键单击解决方案
  2. “管理用于解决方案的 NuGet 包...”,浏览 SlowCheetah
  3. 点击“管理”
  4. 取消选择您的项目,然后单击“确定”
  5. 再次点击“管理”
  6. 选择您的项目并再次单击“确定”

这将重新创建丢失的文件。

于 2014-01-14T14:04:35.203 回答
11
于 2012-11-28T03:45:19.677 回答
6

请注意,您必须为相关项目安装 SlowCheetah Visual Studio 扩展SlowCheetah nuget 包,才能进行转换。

于 2017-02-11T01:53:50.707 回答
5

如上所述重新安装后,我需要将subTypeandtransformOnBuild节点添加到我的 csproj 文件中,它开始为我工作。

<None Include="App.config">
  <SubType>Designer</SubType>
  <TransformOnBuild>true</TransformOnBuild>
</None> 
<None Include="App.QA.config">
  <DependentUpon>App.config</DependentUpon>
  <IsTransformFile>True</IsTransformFile>
</None>
于 2016-12-15T20:30:25.377 回答
3

使用 SlowCheetah 2.5.15 和 Visual Studio 2015,我必须卸载 nuget 包,然后从相关的 .csproj 文件中手动删除以下内容:

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

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

完成此操作并重新安装 SlowCheetah nuget 包后,我的问题就解决了。

于 2016-07-08T16:49:01.160 回答
2

SlowCheetah 3.2.20 添加了一个,呃,“功能”,旨在尊重 Visual Studio 中的“请勿复制”文件设置。因此,如果您没有将 .config 文件设置为“始终复制”或“如果较新则复制”,它不会将它们复制到输出文件夹。

有关详细信息,请参阅https://github.com/Microsoft/slow-cheetah/issues/182

这是我的问题 - 花了三个小时调试它......

于 2019-02-20T20:51:02.130 回答