SlowCheetah转换为非web app.config

时间:2013-03-29 18:26:38

标签: visual-studio-2010 visual-studio msbuild slowcheetah

我对Sayed Hashimi和公司在SlowCheetah上所做的快速和极好的工作感到困惑,特别是SlowCheetah是否能够在Build上转换文件而不仅仅是Package and Publish。

我安装了SlowCheetah,并且能够为我正在与开发团队部署的控制台应用程序的app.config自动生成构建配置实例。在构建时,在$(ProjectDir)\ obj \ x86 \ $(BuildConfig)目录下创建一个新的“SlowCheetah”目录。例如,obj \ x86 \ STAGE \ SlowCheetah目录包含一个app.config文件,当右键单击STAGE变换并选择“View Transforms”时,变换已完成。

然而,\ bin \ $(BuildConfig)目录包含未转换的app.config文件以及每个$(BuildConfig)转换的所有模板 - 而不是替换bin中的app.config文件\ x86 \ STAGE目录与SlowCheetah中的目录。

构建完成且没有错误。

这是预期的操作,还是仍然无法正常工作?

@ sayed-ibrahim-hashimi每个$(配置)都有一个转换。在Visual Studio中查看时,转换显示正确,并在\ obj目录树下的\ slowcheetah目录中正确转换。变换的例子是:

<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform
<connectionStrings>
<add name="Portal" connectionString="Data Source=transformtestserver.domain.local;Initial Catalog=TestDB;User Id=TestUser;Password=testpw1;" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
<add name="DictionaryDatabase" connectionString="Data Source=transformtestserver.domain.local;Initial Catalog=TestDB;User Id=TestUser;Password=testpw2;" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
<add name="LoggingDatabase" connectionString="Data Source=transformtestserver.domain.local;Initial Catalog=TestDB;User Id=TestUser;Password=testpw3;" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>    
</connectionStrings>
</configuration>

问题可能与Nuget /解决方案配置有关。我正在处理的项目是一个非常大的解决方案的一部分。我很难安装和运行SlowCheetah - 有一次发现Nuget说安装了SlowCheetah但是解决方案包目录没有包含SlowCheetah。

我在TeamCity中设置了一个解决方法,从\ obj目录中拾取转换后的app.config文件,但是我真的想解决问题,这样我就可以将SC推广到完整的开发组。是否有一个详细的日志我们可以看一下可能会指出细节?

2 个答案:

答案 0 :(得分:3)

我遇到了同样的问题。

VS中的本地编译效果很好, 但是在构建Agent(TeamCity)时,转换魔法不会发生!

我发现与proj文件中xml元素的位置相关的解决方案

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

我注意到当PropertyGroup高于所有ItemGroup的元素时 MsBuild.exe最后进行了转换

答案 1 :(得分:0)

查找重复的SlowCheetahTargets部分 - 我有一个旧版本和一个较新版本,旧版本指向nuget软件包目录中不再存在的位置。

删除旧版/重复版SlowCheetahTargets部分的整个属性组,并修复它。