将网络配置*元素*替换为msdeploy参数 [英] Replace web config *elements* with msdeploy parameters

查看:120
本文介绍了将网络配置*元素*替换为msdeploy参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用msdeploy(或根据需要进行Web部署)打包和部署Web应用程序.通过声明参数打包时间,我们可以在部署时提供值(以替换连接字符串).

We're using msdeploy (or web deploy if you wish) to package and deploy web apps. By declaring parameters package time we can provide values at deploy time (to replace connection strings among other things).

我们当前面临的问题是替换Web配置中applicationSettings部分中的值.我们无法让msdeploy替换该值,因为要替换的内容是xml元素中的文本,而不是属性值(我们得到的警告是:无法在节点类型'Element'上设置值").

The problem we currently face is replacing values in applicationSettings sections in our web config. We can't get msdeploy to replace the value because the content we want to replace is the text inside an xml element, not an attribute value (the warning we get is: "Cannot set a value on node type 'Element'").

相关配置如下:

<applicationSettings>
  <Name.Of.Assembly.Properties.Settings>
    <setting name="someSetting" serializeAs="String">
      <value>I wanna be replaced</value>
    </setting>
  </Name.Of.Assembly.Properties.Settings>
</applicationSettings>

,声明参数xml如下所示:

and the declare parameter xml looks like this:

<parameter name="XX" defaultValue="default">
  <parameterEntry kind="XmlFile"
                       scope="Web\.config$"
                       match="/configuration/applicationSettings/Name.Of.Assembly.Properties.Settings/setting[@name='someSetting']/value" />
</parameter>

msdeploy仅支持替换属性值还是我做错了什么?

Does msdeploy only support replacing attribute values or am I doing something wrong?

推荐答案

后代...

您只需要在比赛的末尾添加"/text()"即可.这将更改标签所包含的值.但是,该值在源web.config中不能为空.因此,当您使用发布"解决方案配置构建部署程序包时,web.Release.config不得将此设置的此值设置为空值.

You just need to add "/text()" to the end of the match. That will change the value of enclosed by the tags. However, this value cannot be empty in the source web.config. So when you build the deployment package using the "Release" solution configuration, the web.Release.config must not set this value of the setting to an empty value.

<parameter name="XX" defaultValue="default">
  <parameterEntry kind="XmlFile"
                       scope="Web\.config$"
                       match="/configuration/applicationSettings/Name.Of.Assembly.Properties.Settings/setting[@name='someSetting']/value/text()" />
</parameter>

这篇关于将网络配置*元素*替换为msdeploy参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆