Skip to content

Commit

Permalink
Allow dev builds to upgrade all versions (#2818)
Browse files Browse the repository at this point in the history
* Allow dev builds to upgrade all versions

Resolves #2815

* EngSys changes to support release/dev MSI builds

* Ensure using parameters.Condition

* ##vso (thanks, copilot)

* Test: contrive a version update

* Use checked in version.txt

* Use version.txt

* Revert "Use version.txt"

This reverts commit 1da0c1f.

* Revert "Use checked in version.txt"

This reverts commit 64bc097.

* Revert "Test: contrive a version update"

This reverts commit b9092d0.

* Use version.txt from main

---------

Co-authored-by: Daniel Jurek <djurek@microsoft.com>
  • Loading branch information
heaths and danieljurek committed Oct 24, 2023
1 parent e13bfa0 commit 4e0d603
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 17 deletions.
5 changes: 4 additions & 1 deletion cli/installer/windows/azd.wixproj
Expand Up @@ -5,7 +5,8 @@
<SchemaVersion>2.0</SchemaVersion>
<Configuration Condition="'$(Configuration)'==''">Release</Configuration>
<Platform Condition="'$(Platform)' == ''">x64</Platform>
<ProductVersion Condition="'$(CLI_VERSION)' != ''">$(CLI_VERSION)</ProductVersion>
<ProductName Condition="'$(ProductName)' == ''">Azure Developer CLI (dev)</ProductName>
<ReleaseBuild Condition="'$(ProductVersion)' != ''">true</ReleaseBuild>
<ProductVersion Condition="'$(ProductVersion)' == ''">0.1.0</ProductVersion>
<!-- Windows Installer ProductVersion uses only major.minor.patch -->
<ProductVersion Condition="$(ProductVersion.IndexOf('-')) &gt; 0">$(ProductVersion.Substring(0, $(ProductVersion.IndexOf('-'))))</ProductVersion>
Expand All @@ -18,7 +19,9 @@
<IntermediateOutputPath>obj\$(Configuration)</IntermediateOutputPath>
<DefineConstants>
$(DefineConstants);
ProductName=$(ProductName);
ProductVersion=$(ProductVersion);
ReleaseBuild=$(ReleaseBuild);
</DefineConstants>
<SuppressIces Condition="'$(Platform)' == 'arm' Or '$(Platform)' == 'arm64'">ICE39</SuppressIces>
<DefineSolutionProperties>false</DefineSolutionProperties>
Expand Down
21 changes: 16 additions & 5 deletions cli/installer/windows/azd.wxs
@@ -1,12 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>

<?define ProductName = "Azure Developer CLI"?>
<?define ProductFolder = "Azure Dev CLI"?>
<?ifndef ProductName?>
<?error ProductName property not defined?>
<?endif?>

<?ifndef ProductVersion?>
<?error ProductVersion property not defined?>
<?endif?>

<!-- BaseProductName is used for shared registration; should be per-channel (or just use ProductName) if/when channels are supported. -->
<?define BaseProductName = "Azure Developer CLI"?>
<?define ProductFolder = "Azure Dev CLI"?>

<!-- Define a unique UpgradeCode per platform -->
<?if $(var.Platform) = "x64"?>
<?define UpgradeCode = "37533D38-361D-4CDB-939C-B05A9A17B2DA"?>
Expand All @@ -32,7 +37,13 @@
<Property Id="REINSTALLMODE" Value="amus"/>

<!-- Remove older product(s) late but within the transaction to support removing ~\.azd\bin -->
<MajorUpgrade Schedule="afterInstallExecute" DowngradeErrorMessage="A newer version of !(bind.property.ProductName) is already installed."/>
<?if $(var.ReleaseBuild) = "true"?>
<!-- Release builds should still be linear to prevent installing older version. -->
<MajorUpgrade Schedule="afterInstallExecute" DowngradeErrorMessage="A newer version of $(var.BaseProductName) is already installed."/>
<?else?>
<!-- Dev builds should install over any other version installed for easy testing. -->
<MajorUpgrade Schedule="afterInstallExecute" AllowDowngrades="yes"/>
<?endif?>

<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.ProgramFilesFolder)" Name="Program Files">
Expand Down Expand Up @@ -80,8 +91,8 @@

<!-- Override ARP to display full UI during uninstall. -->
<Component Directory="INSTALLDIR">
<RegistryKey Root="HKCU" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\[ProductName]">
<RegistryValue Name="DisplayName" Value="[ProductName]" Type="string" />
<RegistryKey Root="HKCU" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(var.BaseProductName)">
<RegistryValue Name="DisplayName" Value="$(var.BaseProductName)" Type="string" />
<RegistryValue Name="DisplayVersion" Value="[ProductVersion]" Type="string" />
<RegistryValue Name="HelpLink" Value="https://aka.ms/azd/support" Type="string" />
<RegistryValue Name="InstallLocation" Value="[INSTALLDIR]" Type="string" />
Expand Down
7 changes: 7 additions & 0 deletions eng/pipelines/release-cli.yml
Expand Up @@ -111,6 +111,9 @@ stages:
parameters:
Title: Build Test MSI
Condition: and(succeeded(), eq(variables['BuildTestMsi'], 'true'))
# Build the test MSI with the same configuration as the
# release MSI (no special upgrade behavior)
ShouldBuildForRelease: true

- template: /eng/pipelines/templates/steps/install-terraform.yml
- template: /eng/pipelines/templates/steps/install-kubectl.yml
Expand Down Expand Up @@ -601,6 +604,10 @@ stages:
- template: /eng/pipelines/templates/steps/build-msi.yml
parameters:
Title: Build Release MSI
# Only build for release in a manual (releasing) build. Otherwise
# the package version will be 0.1.0 with upgrade logic that allows
# it to be installed over any previously installed version.
ShouldBuildForRelease: ${{ eq(variables['Build.Reason'], 'Manual') }}

- ${{ if and(in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'Manual'), eq(variables['Build.Repository.Name'], 'Azure/azure-dev')) }}:
- template: pipelines/steps/azd-cli-win-signing.yml@azure-sdk-build-tools
Expand Down
49 changes: 38 additions & 11 deletions eng/pipelines/templates/steps/build-msi.yml
Expand Up @@ -2,23 +2,49 @@ parameters:
CliVersion: $(CLI_VERSION)
Title: Build MSI
Condition: succeeded()
# Building for release will specify a version number directly and the MSI will
# be set to fail if it is installed over a later version. If
# ShouldBuildForRelease is false the MSI will be built with the version 0.1.0
# and will always install over any other installed version (even if the
# existing installed version is higher than 0.1.0).
ShouldBuildForRelease: true

steps:
- task: NuGetCommand@2
condition: ${{ parameters.Condition }}
displayName: Restore NuGet packages
inputs:
restoreSolution: cli/installer/windows.sln

- task: PowerShell@2
displayName: Get MSI version from CLI version
condition: ${{ parameters.Condition }}
inputs:
pwsh: true
targetType: filePath
filePath: eng/scripts/Get-MsiVersion.ps1
arguments: >-
-CliVersion "${{ parameters.CliVersion }}"
-DevOpsOutput
- ${{ if eq(parameters.ShouldBuildForRelease, 'true') }}:
# Release build uses version and product name for release
- task: PowerShell@2
displayName: Get MSI version from CLI version
condition: ${{ parameters.Condition }}
inputs:
pwsh: true
targetType: filePath
filePath: eng/scripts/Get-MsiVersion.ps1
arguments: >-
-CliVersion "${{ parameters.CliVersion }}"
-DevOpsOutput
- pwsh: |
Write-Host "##vso[task.setvariable variable=MSI_PRODUCT_NAME_PARAM]/p:ProductName=`"Azure Developer CLI`""
Write-Host "##vso[task.setvariable variable=MSI_VERSION_PARAM]/p:ProductVersion=$(MSI_VERSION)"
condition: ${{ parameters.Condition }}
displayName: Set MSI_PRODUCT_NAME_PARAM for release
- ${{ else }}:
# Leave version and product name empty for dev build (allows dev version to)
# install over any previously installed version. These variables must be set
# or DevOps will substitute in the literal string
# (e.g. '$(MSI_PRODUCT_NAME_PARAM)') into the msbuild command arguments.
- pwsh: |
Write-Host "##vso[task.setvariable variable=MSI_PRODUCT_NAME_PARAM]"
Write-Host "##vso[task.setvariable variable=MSI_VERSION_PARAM]"
condition: ${{ parameters.Condition }}
displayName: Set MSI_PRODUCT_NAME_PARAM and MSI_VERSION_PARAM for dev release
- task: MSBuild@1
displayName: ${{ parameters.Title }}
Expand All @@ -28,4 +54,5 @@ steps:
msbuildArguments: >-
/p:RunWixToolsOutOfProc=true
/p:Configuration=Release
/p:ProductVersion=$(MSI_VERSION)
$(MSI_PRODUCT_NAME_PARAM)
$(MSI_VERSION_PARAM)

0 comments on commit 4e0d603

Please sign in to comment.