Skip to content

Commit d2f17f1

Browse files
committed
Added MSI creation assets and CI/CD integration scripts.
1 parent 8cbebb5 commit d2f17f1

File tree

8 files changed

+154
-10
lines changed

8 files changed

+154
-10
lines changed

azure-pipelines.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ variables:
1919
devops_buildNumber: $[counter(format(''), 1500)]
2020
APPVEYOR_REPO_BRANCH: $[coalesce(variables['System.PullRequest.TargetBranch'], variables['Build.SourceBranchName'])]
2121
APPVEYOR_REPO_COMMIT: $(Build.SourceVersion)
22-
2322
steps:
2423
- pwsh: |
2524
Write-Host "Target branch: '$(APPVEYOR_REPO_BRANCH)'"
@@ -40,7 +39,7 @@ steps:
4039
$accessToken = (az account get-access-token --query "accessToken" | % { $_.Trim('"') })
4140
echo "##vso[task.setvariable variable=azure_management_access_token]$accessToken"
4241
- pwsh: |
43-
.\build.ps1
42+
.\build.ps1 -MsiGenBranches master,v3.x
4443
env:
4544
AzureBlobSigningConnectionString: $(AzureBlobSigningConnectionString)
4645
BuildArtifactsStorage: $(BuildArtifactsStorage)
@@ -56,7 +55,9 @@ steps:
5655
- task: CopyFiles@2
5756
inputs:
5857
SourceFolder: '$(Build.Repository.LocalPath)\artifacts'
59-
Contents: 'Azure.Functions.Cli.*'
58+
Contents: |
59+
Azure.Functions.Cli.*
60+
func-cli*.msi
6061
TargetFolder: '$(Build.ArtifactStagingDirectory)'
6162
CleanTargetFolder: true
6263
- task: PublishBuildArtifacts@1

build.ps1

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
param([String[]] $MsiGenBranches)
2+
3+
$baseDir = Get-Location
14

25
if ($env:APPVEYOR_REPO_BRANCH -eq "disabled") {
36
Set-Location ".\src\Azure.Functions.Cli"
@@ -34,3 +37,54 @@ else {
3437
Invoke-Expression -Command "dotnet run"
3538
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
3639
}
40+
41+
if ($MsiGenBranches.Contains($env:APPVEYOR_REPO_BRANCH)) {
42+
Write-Host "Generating MSI files"
43+
44+
# Add WiX to PATH
45+
if (-not (@($env:Path -split ";") -contains $env:WIX))
46+
{
47+
# Check if the Wix path points to the bin folder
48+
if ((Split-Path $env:WIX -Leaf) -ne "bin")
49+
{
50+
$env:Path += ";$env:WIX\bin"
51+
}
52+
else
53+
{
54+
$env:Path += ";$env:WIX"
55+
}
56+
}
57+
58+
# Get runtime version
59+
$artifactsPath = "$baseDir\artifacts"
60+
$buildDir = "$baseDir\build"
61+
$cli = Get-ChildItem -Path $artifactsPath -Include func.dll -Recurse | Select-Object -First 1
62+
$cliVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($cli).FileVersion
63+
64+
# Generate MSI installers for Windows
65+
@('x64', 'x86') | ForEach-Object {
66+
$platform = $_
67+
$targetDir = "$artifactsPath\win-$platform"
68+
69+
Copy-Item "$buildDir\icon.ico" -Destination $artifactsPath\win-$platform
70+
Copy-Item "$buildDir\license.rtf" -Destination $artifactsPath\win-$platform
71+
Copy-Item "$buildDir\installbanner.bmp" -Destination $artifactsPath\win-$platform
72+
Copy-Item "$buildDir\installdialog.bmp" -Destination $artifactsPath\win-$platform
73+
Set-Location $targetDir
74+
75+
$masterWxsName = "funcinstall"
76+
$fragmentName = "$platform-frag"
77+
$msiName = "func-cli-$cliVersion-$platform"
78+
79+
$masterWxsPath = "$buildDir\$masterWxsName.wxs"
80+
$fragmentPath = "$buildDir\$fragmentName.wxs"
81+
$msiPath = "$artifactsPath\$msiName.msi"
82+
83+
Invoke-Expression "heat dir '.' -cg FuncHost -dr INSTALLDIR -gg -ke -out $fragmentPath -srd -sreg -template fragment -var var.Source"
84+
Invoke-Expression "candle -arch $platform -dPlatform='$platform' -dSource='.' -dProductVersion='$cliVersion' $masterWxsPath $fragmentPath"
85+
Invoke-Expression "light -ext WixUIExtension -out $msiPath -sice:ICE61 $masterWxsName.wixobj $fragmentName.wixobj"
86+
87+
Set-Location $baseDir
88+
Get-ChildItem -Path $targetDir -Recurse | Remove-Item -Force -Recurse -ea SilentlyContinue
89+
}
90+
}

build/BuildSteps.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -425,13 +425,16 @@ public static void Zip()
425425
ColoredConsole.WriteLine($"Creating {shaPath}");
426426
File.WriteAllText(shaPath, ComputeSha256(zipPath));
427427

428-
try
429-
{
430-
Directory.Delete(path, recursive: true);
431-
}
432-
catch
433-
{
434-
ColoredConsole.Error.WriteLine($"Error deleting {path}");
428+
if (!runtime.StartsWith("win")) {
429+
try
430+
{
431+
Directory.Delete(path, recursive: true);
432+
}
433+
catch
434+
{
435+
ColoredConsole.Error.WriteLine($"Error deleting {path}");
436+
}
437+
435438
}
436439

437440
ColoredConsole.WriteLine();

build/funcinstall.wxs

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?xml version='1.0' encoding='windows-1252'?>
2+
<?define Manufacturer='Microsoft'?>
3+
<?define ProductName='Azure Functions Core Tools'?>
4+
5+
<?if $(var.Platform)=x64?>
6+
<?define UpgradeCodeGuid='4E39ECC2-3CAE-43BD-94A6-AF9F97F54684'?>
7+
<?define PathGuid='240C4066-04AB-4F29-8593-079B6FB3C1DA'?>
8+
<?define ProgramMenuDirGuid='C3A3339D-DE95-46E2-8AE0-23C03793B365'?>
9+
<?define PlatformProgramFilesFolder='ProgramFiles64Folder'?>
10+
<?else?>
11+
<?define UpgradeCodeGuid='E8B743C0-51BE-43DF-A344-E995DD3FFD7E'?>
12+
<?define PathGuid='1CF628D0-C094-42EE-AC0B-9C2419A136C4'?>
13+
<?define ProgramMenuDirGuid='09A34A64-54B8-4017-8972-399981526250'?>
14+
<?define PlatformProgramFilesFolder='ProgramFilesFolder'?>
15+
<?endif?>
16+
17+
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
18+
<!-- Product, Package and Upgrade Information -->
19+
<Product Id='*'
20+
Name='$(var.ProductName) - $(var.ProductVersion) ($(var.Platform))'
21+
UpgradeCode='$(var.UpgradeCodeGuid)'
22+
Language='1033'
23+
Codepage='1252'
24+
Version='$(var.ProductVersion)'
25+
Manufacturer='$(var.Manufacturer)'>
26+
27+
<Package Id='*'
28+
Keywords='Azure, Functions, Core Tools, Installer'
29+
Description='$(var.ProductName) $(var.ProductVersion) $(var.Platform) Installer'
30+
Manufacturer='$(var.Manufacturer)'
31+
Comments='Copyright (c) .NET Foundation. All rights reserved. Licensed under the MIT License.'
32+
InstallerVersion='300'
33+
Compressed='yes'
34+
Languages='1033'
35+
SummaryCodepage='1252' />
36+
37+
<MajorUpgrade AllowDowngrades='yes' Schedule='afterInstallInitialize' />
38+
39+
<Media Id='1' Cabinet='funchost.cab' EmbedCab='yes' />
40+
41+
<!-- Directory Structure and Feature Definition -->
42+
<Directory Id='TARGETDIR' Name='SourceDir'>
43+
<Directory Id='$(var.PlatformProgramFilesFolder)' Name='PFiles'>
44+
<Directory Id='$(var.Manufacturer)' Name='$(var.Manufacturer)'>
45+
<Directory Id='INSTALLDIR' Name='$(var.ProductName)'>
46+
<!-- FuncHost componentgroup in fragment -->
47+
<Component Id='Path' Guid='$(var.PathGuid)' KeyPath='yes'>
48+
<Environment Id='UpdatePath' Name='PATH' Value='[INSTALLDIR]' Permanent='no' Part='last' Action='set' System='yes' />
49+
</Component>
50+
</Directory>
51+
</Directory>
52+
</Directory>
53+
54+
<Directory Id='ProgramMenuFolder' Name='Programs'>
55+
<Directory Id='ProgramMenuDir' Name='$(var.ProductName)'>
56+
<Component Id='ProgramMenuDir' Guid='$(var.ProgramMenuDirGuid)'>
57+
<RemoveFolder Id='ProgramMenuDir' On='uninstall' />
58+
<RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' Type='string' Value='' KeyPath='yes' />
59+
</Component>
60+
</Directory>
61+
</Directory>
62+
</Directory>
63+
64+
<Feature Id='Complete'
65+
Level='1'
66+
Title='$(var.ProductName)'
67+
Description='Placeholder description'
68+
Display='expand'>
69+
<ComponentGroupRef Id='FuncHost' />
70+
<ComponentRef Id='ProgramMenuDir' />
71+
<ComponentRef Id='Path' />
72+
</Feature>
73+
74+
<!-- UI -->
75+
<UIRef Id='WixUI_InstallDir' />
76+
<UIRef Id='WixUI_ErrorProgressText' />
77+
<Property Id='WIXUI_INSTALLDIR' Value='INSTALLDIR' />
78+
79+
<Icon Id='icon.ico' SourceFile='icon.ico' />
80+
<Property Id='ARPPRODUCTICON' Value='icon.ico' />
81+
82+
<WixVariable Id='WixUILicenseRtf' Value='license.rtf' />
83+
<WixVariable Id='WixUIBannerBmp' Value='installbanner.bmp' />
84+
<WixVariable Id='WixUIDialogBmp' Value='installdialog.bmp' />
85+
</Product>
86+
</Wix>

build/icon.ico

32 KB
Binary file not shown.

build/installbanner.bmp

83.9 KB
Binary file not shown.

build/installdialog.bmp

451 KB
Binary file not shown.

build/license.rtf

1.26 KB
Binary file not shown.

0 commit comments

Comments
 (0)