首页 文章

SlowCheetah没有在构建时转换文件

提问于
浏览
29

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

(错误xcopy退出代码4)

SlowCheetah似乎没有像我期望的那样转换文件并将其放在输出目录(bin文件夹)中 . 有没有人有任何想法,为什么它没有发生,也许在某处设置?

仅供参考:此过程适用于具有相同项目的另一台计算机 . 至于我可以告诉同样的设置 . 但我可能没有找到正确的地方 .

8 回答

  • 4
  • 8

    对我来说,我发现问题是配置文件中的慢速猎豹属性组低于检查它是否存在的部分 .

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

    把这个:

    <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" />
    
  • 15

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

    • 右键单击解决方案

    • "Manage NuGet Packages for Solution...",浏览SlowCheetah

    • 点击"Manage"

    • 取消选择您的项目,然后单击"Ok"

    • 再次点击"Manage"

    • 选择您的项目并再次点击"Ok"

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

  • 30

    如上所述重新安装后,我需要将 subTypetransformOnBuild 节点添加到我的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>
    
  • 4

    请注意,您必须为相关项目安装SlowCheetah Visual Studio扩展 AND SlowCheetah nuget包,才能使转换正常工作 .

  • 0

    使用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包后,我的问题就解决了 .

  • 0

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

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

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

  • 3

    对我来说它更简单 .

    不需要像@Frank Liu所说的那样同时安装包和扩展 . 它可能会导致您遇到版本不匹配的问题,例如:The "SlowCheetah.Xdt.TransformXml" task could not be loaded from the assembly

    我忘了将 xdt:Transform="Replace" 属性添加到我试图在转换中替换的标记中 .

    如果你像我一样散布,请仔细检查一下 .

相关问题