Skip to content

Commit cad8fff

Browse files
author
maddieclayton
committed
fix build
1 parent 9cd497f commit cad8fff

File tree

2 files changed

+43
-31
lines changed

2 files changed

+43
-31
lines changed

build.proj

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212
1313
/t:Test
1414
Runs tests
15+
16+
/t:Publish
17+
Creates local nuget packages and MSI
1518
1619
/p:CodeSign=True
1720
Code sign binaries, mainly for official release. Default is false.
1821
1922
/p:CodeSign=True;DelaySign=True
20-
Test the code sign workflow locally.
23+
Test the code sign workflow locally.
2124
2225
/p:Scope
2326
'ServiceManagement': service management
@@ -239,11 +242,6 @@
239242
<Copy SourceFiles="$(LibrarySourceFolder)\Stack\$(Configuration)\AzureStack.psm1"
240243
DestinationFolder="$(LibrarySourceFolder)\StackAdmin\AzureStack" Condition= " '$(NetCore)' == 'false' and '$(Stack)' == 'true' "/>
241244
<!-- moved copy tasks -->
242-
243-
<Exec Command="&quot;$(PowerShellCommand)&quot; -NonInteractive -NoLogo -NoProfile -Command &quot;. Register-PSRepository -Name MSIcreationrepository -SourceLocation $(PackageDirectory) -InstallationPolicy Trusted &quot; " Condition=" '$(CodeSign)' == 'true' and '$(Scope)' == 'all'"/>
244-
<Exec Command="&quot;$(PowerShellCommand)&quot; -NonInteractive -NoLogo -NoProfile -Command &quot;. $(LibraryRoot)\setup\generate.ps1 -version 5.0.0 -force -repository MSIcreationrepository &quot; " Condition=" '$(CodeSign)' == 'true' and '$(Scope)' == 'all'"/>
245-
<CallTarget Targets="CodeSignInstaller"
246-
Condition=" '$(CodeSign)' == 'true' and '$(Scope)' == 'all'" />
247245

248246
<Message Importance="high" Text="Running Static Analyser" />
249247
<CallTarget targets="DependencyAnalysis" ContinueOnError="ErrorAndContinue" />
@@ -418,6 +416,14 @@
418416
DestinationFolder="$(LibraryRoot)tools\AzureRM.NetCore" Condition= " '$(NetCore)' == 'true' "/>
419417
</Target>
420418

419+
<Target Name="BuildInstaller">
420+
<Exec Command="&quot;$(PowerShellCommand)&quot; -NonInteractive -NoLogo -NoProfile -Command &quot;. Register-PSRepository -Name MSIcreationrepository -SourceLocation $(PackageDirectory) -InstallationPolicy Trusted &quot; " Condition=" '$(Scope)' == 'all'"/>
421+
<Exec Command="&quot;$(PowerShellCommand)&quot; -NonInteractive -NoLogo -NoProfile -Command &quot;. $(LibraryRoot)\setup\generate.ps1 -repository MSIcreationrepository &quot; " Condition=" '$(Scope)' == 'all'"/>
422+
<Exec Command="&quot;$(PowerShellCommand)&quot; -NonInteractive -NoLogo -NoProfile -Command &quot;. Unregister-PSRepository -Name MSIcreationrepository &quot; " Condition=" '$(Scope)' == 'all'"/>
423+
<CallTarget Targets="CodeSignInstaller"
424+
Condition=" '$(CodeSign)' == 'true' and '$(Scope)' == 'all'" />
425+
</Target>
426+
421427
<Target Name="CodeSignInstaller">
422428
<PropertyGroup>
423429
<!--public token associated with MSSharedLibKey.snk-->
@@ -474,7 +480,9 @@
474480
<Exec Command="&quot;$(PowerShellCommand)&quot; -NonInteractive -NoLogo -NoProfile -Command &quot;. $(LibraryToolsFolder)\PublishModules.ps1 $(NetCore) $(Configuration) $(Scope) $(NuGetKey) \&quot;$(NuGetPublishingSource)\&quot; -Profile Latest &quot; $(NuGetCommand)" Condition="'$(Latest)' == 'true' "/>
475481
<Message Importance="high" Text="Publishing Cmdlets using Stack profile" Condition="'$(Stack)' == 'true' "/>
476482
<Exec Command="&quot;$(PowerShellCommand)&quot; -NonInteractive -NoLogo -NoProfile -Command &quot;. $(LibraryToolsFolder)\PublishModules.ps1 $(NetCore) $(Configuration) $(Scope) $(NuGetKey) \&quot;$(StackPublishingSource)\&quot; -Profile Stack &quot; $(NuGetCommand)" Condition="'$(Stack)' == 'true' " />
477-
</Target>
483+
484+
<CallTarget Targets="BuildInstaller" />
485+
</Target>
478486

479487
<PropertyGroup>
480488
<RunTestLive Condition="'$(RunTestLive)' == ''">false</RunTestLive>

setup/generate.ps1

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616
#>
1717

1818
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",
2421

2522
[Parameter(HelpMessage="Prevent a build number from being tacked on the end of the version number.")]
2623
[Switch]$noBuildNumber,
@@ -36,16 +33,6 @@ if( (-not (get-command -ea 0 light)) -or (-not (get-command -ea 0 heat)) -or (-n
3633

3734
# variables
3835

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-
4936
# output filename (plus '-$version-$arch.msi' )
5037
$outputName ="Azure-Cmdlets"
5138

@@ -61,18 +48,18 @@ $modulesDir = "$tmp\modules"
6148
# archetectures supported
6249
$archs = @('x86','x64')
6350

51+
$scriptLocation = (Get-Item $PSCommandPath).Directory
52+
6453
# 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)
6956

7057
$shhh = mkdir -ea 0 "$tmp"
7158
erase -ea 0 "$tmp/*.wixobj"
7259
erase -ea 0 "$tmp/*.wxi"
7360

74-
erase -ea 0 "$PSSCRIPTROOT/*.wixpdb"
75-
erase -ea 0 "$PSSCRIPTROOT/*.msi"
61+
erase -ea 0 "$scriptLocation/*.wixpdb"
62+
erase -ea 0 "$scriptLocation/*.msi"
7663

7764
# install modules locally.
7865
if ( -not (test-path $modulesDir)) {
@@ -84,6 +71,11 @@ if ( -not (test-path $modulesDir)) {
8471
save-module azure -path $modulesDir -Repository $repository
8572
save-module azurerm -path $modulesDir -Repository $repository
8673

74+
if ($version -eq "0")
75+
{
76+
$version = (Get-ChildItem -Path $modulesDir\AzureRM).Name
77+
}
78+
8779
Write-Host -fore green "Tweaking Modules"
8880
cmd /c dir /a/s/b "$modulesDir\psgetmoduleinfo.xml" |% {
8981
Write-Host -fore Gray " - Patching $_"
@@ -93,6 +85,18 @@ if ( -not (test-path $modulesDir)) {
9385
}
9486
}
9587

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+
96100
# prepare include files
97101
$archs |% {
98102
$arch = $_
@@ -118,22 +122,22 @@ if( $LASTEXITCODE) {
118122
$archs |% {
119123
$arch = $_
120124
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"
122126
if( $LASTEXITCODE) {
123127
write-host -fore red "Failed to compile WiX Script for $arch"
124128
write-host -fore red $out
125129
break;
126130
}
127131

128132
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
130134
if( $LASTEXITCODE) {
131135
write-host -fore red "ERROR: Failed to link MSI for $arch"
132136
write-host -fore red $out
133137
break;
134138
}
135139

136-
write-host -fore cyan "Installer Created: $PSSCRIPTROOT\$outputName-$version-$arch.msi"
140+
write-host -fore cyan "Installer Created: $scriptLocation\$outputName-$version-$arch.msi"
137141
}
138142
if( $LASTEXITCODE) {
139143
# did it fail in the loop?

0 commit comments

Comments
 (0)