Increase version of application.config automatically using powershell after every deployment

半城伤御伤魂 提交于 2019-11-29 16:29:43

AppVersion is the value of an attribute of an <add> node, not the name of a node. Also, you want to extract the value of the node's value attribute, not the node's innerText.

       ,- node name
      /
     /   ,- attribute name
    /   /
   /   /       ,- attribute value
  /   /       /
<add key="AppVersion" value="v0.1.7.21.31.144402">
  something
</add>   \
          `- inner text

Attributes are selected in XPath expressions like this:

//node[@attribute='value']

Change these two lines:

$node = $Test1QABuildVersion.SelectSingleNode("/configuration/site/key/AppVersion")
$PropertyVersion= $node.InnerText

into this:

$node = $Test1QABuildVersion.SelectSingleNode("/configuration/site/add[@key='AppVersion']")
$PropertyVersion= $node.value

and update the version number like this:

$node.value = $newVersion
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!