Visual studio 2010 非web app.config的SlowCheetah转换

Visual studio 2010 非web app.config的SlowCheetah转换,visual-studio-2010,visual-studio,msbuild,slowcheetah,Visual Studio 2010,Visual Studio,Msbuild,Slowcheetah,Sayed Hashimi及其公司在SlowCheetah上所做的快速和出色的工作让我感到困惑,特别是SlowCheetah是否能够在构建时转换文件,而不仅仅是打包和发布 我已经安装了SlowCheetah,并且能够为我正在与开发团队一起部署的控制台应用程序的app.config自动生成构建配置实例。在生成时,将在$(ProjectDir)\obj\x86\$(BuildConfig)目录下创建一个新的“SlowCheetah”目录。例如,obj\x86\STAGE\SlowCheetah目录包

Sayed Hashimi及其公司在SlowCheetah上所做的快速和出色的工作让我感到困惑,特别是SlowCheetah是否能够在构建时转换文件,而不仅仅是打包和发布

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

但是,\ bin\$(BuildConfig)目录包含未转换的app.config文件以及每个$(BuildConfig)转换的所有模板,而不是将bin\x86\STAGE目录中的app.config文件替换为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>


我也面临同样的问题

VS中的本地编译非常有效, 但是在build Agent(TeamCity)上,转换魔法不会发生

我找到的解决方案与项目文件中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>

$([System.IO.Path]::GetFullPath($(MSBuildProjectDirectory)\..\packages\SlowCheetah.2.5.10.3\tools\)
真的
$([System.IO.Path]::GetFullPath($(MSBuildProjectDirectory)\Properties\SlowCheetah\SlowCheetah.Transforms.targets))
$(缓慢的输入路径)
我注意到当
属性组
高于所有ItemGroup的元素时
MsBuild.exe最终执行了转换,查找重复的SlowcheethaTargets部分-我有一个旧版本和一个新版本,旧版本指向的位置不再存在于nuget packages目录中


删除旧的/重复的SlowcheethTargets部分的整个属性组,这将修复它。

App.config应在生成时转换。你能在这里给出更具体的复制步骤吗?您能否尝试插入转换以查看源文件是否正在被修改?回复部分没有提供足够的空间来提供详细的答案,原始帖子中附有对您的问题的详细回答以及转换示例,从@sayed ibrahim hashimi@I开始,我在VS2010中打开了诊断输出,看到app.config正在被转换并保存为application.exe.config,其中确实包含正确转换的web.$(Condition).config文件。我查阅了exe.config文件的详细信息,发现这是Windows可执行文件的正确行为。我在找app.config文件。看起来我在这件事上浪费了你的时间-谢谢你的反应,写了很棒的应用程序和书籍。出于这样或那样的原因,每周使用最多的是MSBUILD第二版。@EHuggins我遇到了一个非常类似的问题。尽管我在App.config文件中引用了其他配置文件;我希望转换这些配置文件的内容。和您一样,我看到了一个output Application.exe.config,但它只是包含指向引用的配置文件的原始链接,并且文件本身不会以任何方式进行转换。有什么想法吗?非常感谢您的任何建议。请参阅此帖子(特别是上一篇关于Properties->SlowCheetah->SlowCheetah.Transforms.targets Up vote的帖子,不是因为这是我的答案,而是它指向了正确的查找位置。我必须更新我的
元素中的路径以匹配我的SlowCheetah文件的位置。构建服务器上的位置与defaul文件不同在我的机器上,从慢速安装。