我不想在所有构建服务器上安装 Slow Cheetah。

我们使用 Slow Cheetah 进行配置转换,它运行得非常好。它生成多个 app.config 文件,我们根据需要对它们进行更改。

我们设置了几台服务器。他们都有自己的代码存储库,他们从命令行提取代码并相应地构建包。这些代码中有这些配置文件。但是,当我们从命令行编译应用程序时,如果没有安装 Slow cheetah,则不会通过转换生成包。否则它工作正常。

我们永远不知道何时设置新服务器和新用户,因此不可能在每个服务器上安装 Slow cheetah

是否有可能以某种方式在应用程序中使用慢速的 cheetah dll 并从中手动调用转换方法?

谢谢

有帮助吗?

其他提示

作为慢速切割的替代方法,可以通过手动编辑项目文件来处理此功能。设置有点繁琐,但它确实意味着您没有必需的额外DLL。

在文本编辑器中打开项目文件。在项目文件底部,就在关闭标签之前,包括以下内容:

<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="AfterCompile" Condition="exists('app.$(Configuration).config')">
    <!-- Generate transformed app config in the intermediate directory -->
    <TransformXml Source="app.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="app.$(Configuration).config" />
    <!-- Force build process to use the transformed configuration file from now on. -->
    <ItemGroup>
        <AppConfigWithTargetPath Remove="app.config" />
        <AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config">
            <TargetPath>$(TargetFileName).config</TargetPath>
        </AppConfigWithTargetPath>
    </ItemGroup>
</Target>
.

然后,在项目文件中找到该行并用以下内容替换:

<ItemGroup>
    <Content Include="App.config" />
    <Content Include="App.Debug.config">
        <DependentUpon>App.config</DependentUpon>
    </Content>
    <Content Include="App.Release.config">
        <DependentUpon>App.config</DependentUpon>
    </Content>
</ItemGroup>
.

您需要为您添加的每个配置添加额外的内容 - 不幸的是使用此方法,您不会获得简单的“添加变换”上下文菜单。

之后,它是一个在项目目录中创建文件的情况,然后您就可以进入。它不像慢速表那样光滑,但它确实保持了代码便携式。

最新版本的慢速(2.5.14)在 nuget 中有。通过nuget添加它存储在本地解决方案目录(如所有Nuget软件包中的packages文件夹中,这意味着它现在应该在框中的任何构建服务器上工作。

我将 SlowCheetah 包含在应用程序中,如下所示,以避免将其安装在构建解决方案的服务器上:

  1. 在我的解决方案根目录中,我有一个文件夹 Tools,其中包含(除其他外)SlowCheetah
    1. myProject/Tools/SlowCheetah/SlowCheetah.Tasks.dll
    2. myProject/Tools/SlowCheetah/SlowCheetah.Transforms.targets
  2. 在(网络)应用程序项目的 .csproj 文件中,我有以下内容:

  <PropertyGroup>
          <SlowCheetahTargets Condition=" '$(SlowCheetahTargets)'=='' ">$(MSBuildProjectDirectory)\..\Tools\SlowCheetah\SlowCheetah.Transforms.targets  </SlowCheetahTargets>
   </PropertyGroup>

和这个:

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

..即使是从 TeamCity 构建/发布,它似乎也能很好地处理这项工作。

编辑:

您将找到中提到的两个文件 %localappdata%\Microsoft\MSBuild\SlowCheetah\v1 (drive:\Users\yourusername\AppData\Local\Microsoft\MSBuild\SlowCheetah\v1)当您将 SlowCheetah 安装到 Visual Studio 中时。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top