-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathupdate-version.ps1
More file actions
28 lines (24 loc) · 818 Bytes
/
Copy pathupdate-version.ps1
File metadata and controls
28 lines (24 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
param ($projectpath, $version)
$absolutePath = Resolve-Path -Path $projectpath
$csproj = New-Object xml
$csproj.PreserveWhitespace = $true
$csproj.Load($absolutePath)
$versionElement = $csproj.SelectSingleNode("/Project/PropertyGroup/Version")
$newVersion = $version
if ([string]::IsNullOrEmpty($newVersion)) {
$parts = $versionElement.InnerText.split(".")
$release = [int]$parts[2]
$parts[2] = [string]($release + 1)
$newVersion = $parts -join "."
}
$versionElement.InnerText = $newVersion
$settings = New-Object System.Xml.XmlWriterSettings
$settings.Encoding = [System.Text.Encoding]::UTF8
$settings.OmitXmlDeclaration = $true
$writer = [System.Xml.XmlWriter]::Create($absolutePath, $settings)
try {
$csproj.Save($writer)
} finally {
$writer.Close()
}
Write-Output "::set-output name=version::$newVersion"