我可以使用 Web Deploy 将元素插入到 web.config 中吗?
是否可以使用 Web Deploy 的 Parameters.xml 系统?
XmlFile 参数“kind”似乎是最接近我需要的,但它的 match
属性只接受 XPath 查询,而我似乎无法在我的 XPath 查询中指定不存在的元素。 (或者更确切地说,我可以指定一个不存在的元素 - Web 部署只是忽略它。)具体来说,我想将其转换
<configuration>
<plugins>
<add name="bleh"/>
</plugins>
</configuration>
为:(
<configuration>
<plugins>
<add name="bleh">
<option name="foo" value="bar"/>
</add>
</plugins>
</configuration>
不幸的是,我无法预先存储网络.config 带有空的 option
元素,因为这个特定的插件系统不喜欢无法识别/空的选项。)
感谢您的任何想法!
Is it possible to insert an XML element into my web.config using Web Deploy's Parameters.xml system?
The XmlFile parameter "kind" appears to be the closest to what I need, but its match
attribute only accepts an XPath query, and I don't appear to be able to specify a non-existent element in my XPath query. (Or rather, I can specify a non-existent element - Web Deploy just ignores it.) Specifically, I would like to transform this:
<configuration>
<plugins>
<add name="bleh"/>
</plugins>
</configuration>
into this:
<configuration>
<plugins>
<add name="bleh">
<option name="foo" value="bar"/>
</add>
</plugins>
</configuration>
(Unfortunately I can't pre-stock the web.config with an empty option
element because this particular plugin system doesn't like unrecognized/empty options.)
Thanks for any ideas!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
现在从 Web Deploy V3 开始,这样的事情就成为可能。
请参阅官方文档。
Such things are now possible starting with the Web Deploy V3.
See the official documentation.
Xpath 只是 XML 文档的一种查询语言——它本身不能更改 XML 文档或创建新的 XML 文档。
专门为转换 XML 文档而设计的语言称为 XSLT。
这是一个非常简短的 XSLT 转换,可以解决您的问题:
当此转换应用于提供的 XML 文档时:
生成所需的正确结果< /强>:
Xpath is only a query language for XML documents -- it cannot by itself change an XML document or create a new XML document.
The language especially designed for transforming an XML document is called XSLT.
Here is a very short and simple XSLT transformation that solves your problem:
when this transformation is applied on the provided XML document:
the wanted, correct result is produced:
您是否考虑过使用 配置源?这允许您将配置文件分割成多个较小的文件。 web.config 将从:
使用 configSource 到此:
缺点是在部署期间您不会获得用于编辑配置值的良好 UI。如果您无法使参数化工作,则需要考虑这一点。如果安装 UI 正是您想要的,那么您可以为管理员编写一个编辑工具,该工具可以创建和修改 plugin.xml 文件。
Have you considered using configSource? This allows you to split up your configuration files into multiple smaller files. The web.config would go from:
To this with configSource:
The downside is You won't get a nice UI for editing config values during deployment. It is something to consider if you cannot get parameterization to work. If the install UI is what you are after then you could code an editing tool for your admins that can create and modify the plugin.xml files..
您可以使用常规的 web.config 转换实践吗? http://blogs .msdn.com/b/webdevtools/archive/2009/05/04/web-deployment-web-config-transformation.aspx
您可以执行下面的代码,该代码将用下面的代码替换您的所有部分。实际上,如果问题是您的 Web.Release.config 文件,那么您的问题中的内容应该用您提供的部分替换整个部分。
Web.Release.config:
Can you just use the regular web.config transformation practices? http://blogs.msdn.com/b/webdevtools/archive/2009/05/04/web-deployment-web-config-transformation.aspx
You can do the code below which will replace all of your section with the one below. Actually, what you have in your questions should replace your entire section with the one you provided if it was your Web.Release.config file.
Web.Release.config: