forked from Azure/azure-iot-sdk-csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
versionupdate.ps1
76 lines (57 loc) · 1.83 KB
/
versionupdate.ps1
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
<#
.SYNOPSIS
Microsoft Azure IoT SDK .NET version update script.
.DESCRIPTION
Updates the versions of the Azure IoT SDK components.
Parameters:
-verify Verifies if the versions correspond with the ones in versions.csv.
-update Updates the project versions with the ones in versions.csv.
.EXAMPLE
.\build.ps1
.NOTES
This tool changes the CSPROJ files.
.LINK
https://github.com/azure/azure-iot-sdk-csharp
#>
Param(
[switch] $update
)
Function GetVersion($path) {
$extension = Split-Path -leaf $path
$x = [xml](Get-Content $path)
$versionNode = Select-Xml "//Version" $x
return $versionNode
}
Function UpdateVersion($path, $currentVersion, $desiredVersion) {
$actual = "<Version>$currentVersion</Version>"
$desired = "<Version>$desiredVersion</Version>"
(Get-Content $path) -replace $actual, $desired | Set-Content -Encoding UTF8 $path
}
$csv = Import-Csv versions.csv
$requireUpdate = 0
foreach ($project in $csv) {
Write-Host -ForegroundColor Cyan (Split-Path -leaf $project.AssemblyPath)
$desiredVersion = $project.Version
$actualVersionNode = GetVersion($project.AssemblyPath)
$actualVersion = $actualVersionNode.Node.InnerText
if ($actualVersion -ne $desiredVersion)
{
$requireUpdate++
if ($update)
{
Write-Host -Foreground Green "`tVersion: $actualVersion Desired: $desiredVersion"
UpdateVersion $project.AssemblyPath $actualVersion $desiredVersion
}
else
{
Write-Host -Foreground Red "`tVersion: $actualVersion Desired: $desiredVersion"
}
}
else
{
Write-Host "`tVersion: $actualVersion"
}
}
exit $requireUpdate