简体   繁体   English

使用FAKE F#MAKE更新XML文件

[英]Updating an XML File with FAKE F#MAKE

How do I update attributes in an XML file with FAKE ? 如何使用FAKE更新XML文件中的属性?

I want to update a xml file from fake . 我想从fake更新xml文件。 Actually there is version_no kind of thing that are generated by teamcity , and i have to update that version no in version.config file . 实际上,teamcity不会生成version_no某种东西,我必须在version.config文件中更新该版本号。

I have seen that it can be done using XMLHelper class but i am not getting how to use this . 我已经知道可以使用XMLHelper类完成此操作,但是我没有得到如何使用它的信息。

here is the xml file : 这是xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<version-info>
  <major-version number="1">
    <minor>1-aplha</minor>
    <build>123</build>
    <revision>112</revision>
  </major-version>
</version-info>

For example : I need to change major version , minor , build , revision to 2 , 1 , 12 , 123 respectively . 例如:我需要将主要版本,次要版本,构建版本,修订版本分别更改为2、1、12、123。

How will I do this ?? 我将如何做?

I made a quick edit to a 'build.fsx' file of mine. 我对我的“ build.fsx”文件进行了快速编辑。 The edit looks like this: 修改如下:

// Build the main module with MSBuild
Target "BuildMain" (fun _ ->
  XMLHelper.XmlPokeInnerText "./myxml.xml" "/version-info/major-version/minor" "now-beta"
  !! "./Kapoin_03_Main/Kapoin_03_Main.fsproj"
  |> MSBuild buildDir "Build" buildProps
  |> Log "Main build output: " )

During the build it edits 'myxml.xml' and replaces the value inside the minor tag. 在构建过程中,它会编辑“ myxml.xml”并替换次要标记中的值。 The edited XML then looks like this: 然后,编辑后的XML如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<version-info>
  <major-version number="1">
    <minor>now-beta</minor>
    <build>123</build>
    <revision>112</revision>
  </major-version>
</version-info>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM