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

后端 未结 1 747
一生所求
一生所求 2020-12-21 13:28

I am new to powershell and I wanted to change version in an xml file after every deployment and. I referred to Unable to update a value in msbuild proj file using powershell

相关标签:
1条回答
  • 2020-12-21 14:08

    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
    
    0 讨论(0)
提交回复
热议问题