SlowCheetah Web.config Transformation Syntax now generalized for any XML configuration file

SlowCheetah - Web.config Transformation Syntax now generalized for any XML configuration file

1.通过NuGet安装https://www.nuget.org/packages/Microsoft.VisualStudio.SlowCheetah/

2.通过vs的configuration manager添加新的配置

3.右键选中App.config, add transform就可以自动添加App.Debug.config和App.Release.Config,

如果你有自己另外添加配置,比如Test,也会自动生成App.Test.config

也可以直接安装插件,然后右键add transform。这个插件本身会帮你安装NuGet和生成文件。

https://marketplace.visualstudio.com/items?itemName=vscps.SlowCheetah-XMLTransforms

SlowCheetah vs插件

Transform xml and json files at build time based on configuration. Contains tooling to assist in the creation and previewing of transform files.

根据文件类型不同,菜单和行为都有区别

Web.config的右键菜单是 Add Config Transform,

行为:会根据configuration manager里面的种类来添加Web.Test.config这种文件,项目文件的修改仅仅包含引用这些新生成的文件。

App.config的右键菜单是Add Transform

行为:会根据configuration manager里面的种类来添加Web.Test.config这种文件,

          项目文件的时候,会多出

<TransformOnBuild>true</TransformOnBuild>以及

<Import Project="..\..\Solution\packages\Microsoft.VisualStudio.SlowCheetah.4.0.8\build\Microsoft.VisualStudio.SlowCheetah.targets" Condition="Exists('..\..\Solution\packages\Microsoft.VisualStudio.SlowCheetah.4.0.8\build\Microsoft.VisualStudio.SlowCheetah.targets')" />
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\..\Solution\packages\Microsoft.VisualStudio.SlowCheetah.4.0.8\build\Microsoft.VisualStudio.SlowCheetah.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\Solution\packages\Microsoft.VisualStudio.SlowCheetah.4.0.8\build\Microsoft.VisualStudio.SlowCheetah.targets'))" />
  </Target>

另外,当你右键选中比如Web.Debug.config上,有一个preview transorm的菜单,可以预览transform apply之后的效果。

原文地址:https://www.cnblogs.com/chucklu/p/15649902.html