xml SlowCheetah 在构建时不转换文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13500789/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 13:47:18  来源:igfitidea点击:

SlowCheetah not transforming file on build

xmlweb.config-transformslowcheetahxdt-transformconfig-transformation

提问by Richard S.

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

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

(error xcopy exited with code 4)

(错误 xcopy 以代码 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?

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

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.

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

采纳答案by user1858286

  • 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.configfiles but not web.configson debug at present. It should put a transformed web.configfile in the binfolder of your project but your project still reads from the config filein 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.

回答by laurencee

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

回答by Thorsten Hüglin

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

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

  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"
  1. 右键单击解决方案
  2. “Manage NuGet Packages for Solution...”,浏览SlowCheetah
  3. 点击“管理”
  4. 取消选择您的项目并单击“确定”
  5. 再次点击“管理”
  6. 选择您的项目并再次单击“确定”

This will recreate the missing file.

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

回答by Hink

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

如上所述重新安装后,我需要将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>

回答by Frank Liu

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

请注意,您必须为相关项目安装 SlowCheetah Visual Studio 扩展SlowCheetah nuget 包,以便转换工作。

回答by James Blake

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:

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

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

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

回答by Ken Smith

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.

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

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

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

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

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