1+ [CmdletBinding ()]
2+ Param (
3+ [Parameter (Mandatory = $True , Position = 0 )]
4+ [String ]$Version ,
5+ [Parameter (Mandatory = $True , Position = 1 )]
6+ [String ]$Release ,
7+ [Parameter (Mandatory = $False , Position = 2 )]
8+ [String ]$Folder
9+ )
10+
11+ function SetMsiVersion ([string ]$FilePath , [string ]$MsiVersion )
12+ {
13+ $wxsPath = Join-Path $FilePath " setup\azurecmd.wxs"
14+
15+ Write-Output " Updating File: $wxsPath "
16+ $content = Get-Content $wxsPath
17+ $matches = ([regex ]::matches($content , ' \<\?define version="([\d\.]+)" \?\>' ))
18+
19+ $prevousVersion = $matches.Groups [1 ].Value
20+
21+ $content = $content.Replace (" <?define version=`" $prevousVersion `" ?>" , " <?define version=`" $MsiVersion `" ?>" )
22+
23+ Set-Content - Path $wxsPath - Value $content - Encoding UTF8
24+ }
25+
26+ function SetMsiReleaseString ([string ]$FilePath , [string ]$MsiRelease )
27+ {
28+ $wxsPath = Join-Path $FilePath " setup\azurecmd.wxs"
29+
30+ Write-Output " Updating File: $wxsPath "
31+ $content = Get-Content $wxsPath
32+ $matches = ([regex ]::matches($content , ' \<\?define productName="Microsoft Azure PowerShell - ([a-zA-z]+\s[\d]+)" \?\>' ))
33+
34+ $prevousVersion = $matches.Groups [1 ].Value
35+
36+ $content = $content.Replace (" <?define productName=`" Microsoft Azure PowerShell - $prevousVersion `" ?>" , " <?define productName=`" Microsoft Azure PowerShell - $MsiRelease `" ?>" )
37+
38+ Set-Content - Path $wxsPath - Value $content - Encoding UTF8
39+ }
40+
41+ function AlignAsmPsdReleaseVersion ([string ]$FilePath , [string ]$MsiVersion )
42+ {
43+ $psd1Path = Join-Path $FilePath " src\ServiceManagement\Services\Commands.Utilities\Azure.psd1"
44+
45+ $content = Get-Content $psd1Path
46+ $matches = ([regex ]::matches($content , " ModuleVersion = '([\d\.]+)'\s+" ))
47+
48+ $packageVersion = $matches.Groups [1 ].Value
49+ Write-Output " Updating version of $psd1Path from $packageVersion to $MsiVersion "
50+ $content = $content.Replace (" ModuleVersion = '$packageVersion '" , " ModuleVersion = '$MsiVersion '" )
51+
52+ Set-Content - Path $psd1Path - Value $content - Encoding UTF8
53+ }
54+
55+ function AlignArmPsdReleaseVersion ([string ]$FilePath , [string ]$MsiVersion )
56+ {
57+ $psd1Path = Join-Path $FilePath " tools\AzureRM\AzureRM.psd1"
58+
59+ $content = Get-Content $psd1Path
60+ $matches = ([regex ]::matches($content , " ModuleVersion = '([\d\.]+)'\s+" ))
61+
62+ $packageVersion = $matches.Groups [1 ].Value
63+ Write-Output " Updating version of $psd1Path from $packageVersion to $MsiVersion "
64+ $content = $content.Replace (" ModuleVersion = '$packageVersion '" , " ModuleVersion = '$MsiVersion '" )
65+
66+ Set-Content - Path $psd1Path - Value $content - Encoding UTF8
67+ }
68+
69+ if (! $Folder )
70+ {
71+ $Folder = " $PSScriptRoot \.."
72+ }
73+
74+ SetMsiVersion $Folder $Version
75+ SetMsiReleaseString $Folder $Release
76+ AlignAsmPsdReleaseVersion $Folder $Version
77+ AlignArmPsdReleaseVersion $Folder $Version
0 commit comments