可以通过configSource链接到web.config的部分配置文件在Web项目中转换吗?

Ric*_*zzi 8 xslt web-config transform appsettings slowcheetah

寻找任何与SlowCheetah合作的人在Web项目下转换配置文件的帮助.我们发现从web.config引用的部分配置文件没有被转换.

例如,我们在web.config中包含对部分配置AppSettings.config和ConnectionsString.config的引用,如下所示:

  </system.web>
  <connectionStrings configSource ="ConnectionsString.config"></connectionStrings>
  <appSettings configSource ="AppSettings.config"></appSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)

然后在AppSettings.config中我们只有AppSettings部分,如下所示:

<appSettings>
  <add key="LostPasswordBCC" value="knock@timmons.com" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)

最后在转换文件AppSettings.Debug.config中我们有一些补充:

<?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">
  <appSettings >
    <add key="Release" value="Something" xdt:Transform="Insert" />
  </appSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)

显然上面只是一个测试,看看转换发生了,但我们发现的是,在尝试预览转换时,我们得到的所有内容都是错误"处理转换时出错".发布尝试也失败了.

如果我们使配置文件完全形成xml而不是从web.config引用,那么转换似乎工作正常 - 但是希望在多个项目之间共享这些文件.

有没有人知道是否有一个解决方法,我们既可以从web.config引用部分配置,也可以转换那些部分文件?我们正在处理遗留代码,其中包含大量尝试合并的Web项目中的配置文件,因此需要从Web配置链接到单独的共享文件.

Ric*_*zzi 4

在 Sayed 的帮助下,问题已经解决,我们确定在努力了解 Web 项目的配置转换过程时,我们损坏了转换配置文件的格式。通过新创建的配置文件,我们能够使用 SlowCheetah 进行转换。

这使我们能够继续解决我们需要解决的实际问题,即希望使用 Visual Studio 2012 的发布配置文件转换除 web.config 之外的项目配置。这最初不起作用,但 Sayed 再次帮助我们,并提供了一个新的 SlowCheetah 副本,使其能够起作用。

以下是包含修复程序的新版本 SlowCheetah 的链接: https: //github.com/sayedihashimi/slow-cheetah/issues/46

非常感谢赛义德的所有时间和耐心。