.net - 我可以使用Web Deploy将元素插入web.config吗?

标签 .net xslt xpath msdeploy webdeploy

是否可以使用Web Deploy的Parameters.xml system将XML元素插入到我的web.config中?

XmlFile 参数“kind”似乎与我需要的参数最接近,但其match属性仅接受XPath查询,而且我似乎无法在XPath查询中指定不存在的元素。 (或者,我可以指定一个不存在的元素-Web Deploy会忽略它。)具体来说,我想对此进行转换:

<configuration>
   <plugins>
      <add name="bleh"/>
   </plugins>
</configuration>

到这个:
<configuration>
   <plugins>
      <add name="bleh">
        <option name="foo" value="bar"/>
      </add>
   </plugins>
</configuration>

(不幸的是,我无法在web.config中预存一个空的option元素,因为此特定的插件系统不喜欢无法识别的/空的选项。)

感谢您的任何想法!

最佳答案

从Web Deploy V3开始,这样的事情现在成为可能。
参见official documentation

Here is one example of a parameters.xml file which will add newNode to all nodes including the root in target xml file:


<parameters>
  <parameter name="Additive" description="Add a node" defaultValue="&lt;newNode />" tags="">
    <parameterEntry kind="XmlFile" scope=".*" match="//*" />
  </parameter>
</parameters>

关于.net - 我可以使用Web Deploy将元素插入web.config吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5719745/

相关文章:

.net - 有没有办法强制 "Any CPU"编译的应用程序在 64 位操作系统上以 32 位模式运行?

Python XPath 语法错误 : invalid predicate

xslt - 如何在 XML 文件中的多个位置添加一些复杂的结构

html - hInserting line-break into XML 以便它出现在 VB.NET 中的 XSL 呈现之后

xml - 什么是 strip 错误?

python - Selenium 不会返回文本

iphone - 在 Cocoa 中解析 NSXMLElement

c# - 从 Excel 单元格读取十进制值(在 C# 中)

c# - 在 .Net 中为整个句子实现 soundex

asp.net - 从 ASP.NET 中的 URL 获取数据