16
16
#>
17
17
18
18
param (
19
- [Parameter (HelpMessage = " The version number for the generated MSI." )]
20
- [string ]$version ,
21
-
22
- [Parameter (HelpMessage = " Forces a fresh installation of the Azure and AzureRm cmdlets from the gallery" )]
23
- [Switch ]$force ,
19
+ [Parameter (HelpMessage = " The version number for the generated MSI. This will be obtained from the AzureRM module if not specified." )]
20
+ [string ]$version = " 0" ,
24
21
25
22
[Parameter (HelpMessage = " Prevent a build number from being tacked on the end of the version number." )]
26
23
[Switch ]$noBuildNumber ,
@@ -36,16 +33,6 @@ if( (-not (get-command -ea 0 light)) -or (-not (get-command -ea 0 heat)) -or (-n
36
33
37
34
# variables
38
35
39
- # the build number is the number of commits in this branch.
40
-
41
- if ( -not $noBuildNumber ) {
42
- # useful for an ever-increasing number that can be tracked to a commit.
43
- $buildNumber = git rev- list -- parents HEAD -- count -- full- history
44
-
45
- # tack the build number onto the version
46
- $version = " $version .$buildNumber "
47
- }
48
-
49
36
# output filename (plus '-$version-$arch.msi' )
50
37
$outputName = " Azure-Cmdlets"
51
38
@@ -61,18 +48,18 @@ $modulesDir = "$tmp\modules"
61
48
# archetectures supported
62
49
$archs = @ (' x86' , ' x64' )
63
50
51
+ $scriptLocation = (Get-Item $PSCommandPath ).Directory
52
+
64
53
# cleanup first
65
- if ( $force ) {
66
- Write-Host - fore yellow " Forcing clean install"
67
- $shhh = (cmd.exe / c rmdir / s / q $tmp )
68
- }
54
+ Write-Host - fore yellow " Forcing clean install"
55
+ $shhh = (cmd.exe / c rmdir / s / q $tmp )
69
56
70
57
$shhh = mkdir - ea 0 " $tmp "
71
58
erase - ea 0 " $tmp /*.wixobj"
72
59
erase - ea 0 " $tmp /*.wxi"
73
60
74
- erase - ea 0 " $PSSCRIPTROOT /*.wixpdb"
75
- erase - ea 0 " $PSSCRIPTROOT /*.msi"
61
+ erase - ea 0 " $scriptLocation /*.wixpdb"
62
+ erase - ea 0 " $scriptLocation /*.msi"
76
63
77
64
# install modules locally.
78
65
if ( -not (test-path $modulesDir )) {
@@ -84,6 +71,11 @@ if ( -not (test-path $modulesDir)) {
84
71
save-module azure - path $modulesDir - Repository $repository
85
72
save-module azurerm - path $modulesDir - Repository $repository
86
73
74
+ if ($version -eq " 0" )
75
+ {
76
+ $version = (Get-ChildItem - Path $modulesDir \AzureRM).Name
77
+ }
78
+
87
79
Write-Host - fore green " Tweaking Modules"
88
80
cmd / c dir / a/ s/ b " $modulesDir \psgetmoduleinfo.xml" | % {
89
81
Write-Host - fore Gray " - Patching $_ "
@@ -93,6 +85,18 @@ if ( -not (test-path $modulesDir)) {
93
85
}
94
86
}
95
87
88
+ # the build number is the number of commits in this branch.
89
+ if ( -not $noBuildNumber ) {
90
+ # useful for an ever-increasing number that can be tracked to a commit.
91
+ $buildNumber = git rev- list -- parents HEAD -- count -- full- history
92
+
93
+ # tack the build number onto the version
94
+ if ($buildNumber -ne $null )
95
+ {
96
+ $version = " $version .$buildNumber "
97
+ }
98
+ }
99
+
96
100
# prepare include files
97
101
$archs | % {
98
102
$arch = $_
@@ -118,22 +122,22 @@ if( $LASTEXITCODE) {
118
122
$archs | % {
119
123
$arch = $_
120
124
Write-Host - fore green " Compiling Wix Script for $arch "
121
- $out = candle - arch $arch - ext WixUIExtension " -dversion=$version " - sw1118 - nologo " -I$tmp " " -dtmp=$tmp " " -dmodulesDir=$modulesDir " " -dproductName=$productName " $PSScriptRoot \azurecmd.wxs - out " $tmp \$outputName -$version -$arch .wixobj"
125
+ $out = candle - arch $arch - ext WixUIExtension " -dversion=$version " - sw1118 - nologo " -I$tmp " " -dtmp=$tmp " " -dmodulesDir=$modulesDir " " -dproductName=$productName " $scriptLocation \azurecmd.wxs - out " $tmp \$outputName -$version -$arch .wixobj"
122
126
if ( $LASTEXITCODE ) {
123
127
write-host - fore red " Failed to compile WiX Script for $arch "
124
128
write-host - fore red $out
125
129
break ;
126
130
}
127
131
128
132
Write-Host - fore green " Creating installer for $arch "
129
- $out = light " $tmp \$outputName -$version -$arch .wixobj" - ext WixUIExtension - out " $PSSCRIPTROOT \$outputName -$version -$arch .msi" - sw1076 - sice:ICE80 - nologo
133
+ $out = light " $tmp \$outputName -$version -$arch .wixobj" - ext WixUIExtension - out " $scriptLocation \$outputName -$version -$arch .msi" - sw1076 - sice:ICE80 - nologo - b $scriptLocation
130
134
if ( $LASTEXITCODE ) {
131
135
write-host - fore red " ERROR: Failed to link MSI for $arch "
132
136
write-host - fore red $out
133
137
break ;
134
138
}
135
139
136
- write-host - fore cyan " Installer Created: $PSSCRIPTROOT \$outputName -$version -$arch .msi"
140
+ write-host - fore cyan " Installer Created: $scriptLocation \$outputName -$version -$arch .msi"
137
141
}
138
142
if ( $LASTEXITCODE ) {
139
143
# did it fail in the loop?
0 commit comments