azure-iot-sdk-csharp/versionupdate.ps1

77 строки
1.8 KiB
PowerShell
Исходник Постоянная ссылка Обычный вид История

2018-02-28 03:43:11 +03:00
# 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
2018-02-28 03:43:11 +03:00
$x = [xml](Get-Content $path)
$versionNode = Select-Xml "//Version" $x
2018-02-28 03:43:11 +03:00
return $versionNode
}
Function UpdateVersion($path, $currentVersion, $desiredVersion) {
$actual = "<Version>$currentVersion</Version>"
$desired = "<Version>$desiredVersion</Version>"
2018-02-28 03:43:11 +03:00
(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