From 4e0d603a4f26821c88877278ce806be85e1b269d Mon Sep 17 00:00:00 2001 From: Heath Stewart Date: Tue, 24 Oct 2023 11:35:38 -0700 Subject: [PATCH] Allow dev builds to upgrade all versions (#2818) * 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 1da0c1fb22e5a01941b007e299f9474c6b63a6e6. * Revert "Use checked in version.txt" This reverts commit 64bc0972998a8ff517c18c6b23e6a8ee3222aabd. * Revert "Test: contrive a version update" This reverts commit b9092d02792b1fce8a6a5154e1eeb44d53c47865. * Use version.txt from main --------- Co-authored-by: Daniel Jurek --- cli/installer/windows/azd.wixproj | 5 ++- cli/installer/windows/azd.wxs | 21 ++++++--- eng/pipelines/release-cli.yml | 7 +++ eng/pipelines/templates/steps/build-msi.yml | 49 ++++++++++++++++----- 4 files changed, 65 insertions(+), 17 deletions(-) diff --git a/cli/installer/windows/azd.wixproj b/cli/installer/windows/azd.wixproj index 85b42fb6cd..1890778dae 100644 --- a/cli/installer/windows/azd.wixproj +++ b/cli/installer/windows/azd.wixproj @@ -5,7 +5,8 @@ 2.0 Release x64 - $(CLI_VERSION) + Azure Developer CLI (dev) + true 0.1.0 $(ProductVersion.Substring(0, $(ProductVersion.IndexOf('-')))) @@ -18,7 +19,9 @@ obj\$(Configuration) $(DefineConstants); + ProductName=$(ProductName); ProductVersion=$(ProductVersion); + ReleaseBuild=$(ReleaseBuild); ICE39 false diff --git a/cli/installer/windows/azd.wxs b/cli/installer/windows/azd.wxs index 6f43d9e4ce..53db847f71 100644 --- a/cli/installer/windows/azd.wxs +++ b/cli/installer/windows/azd.wxs @@ -1,12 +1,17 @@ - - + + + + + + + @@ -32,7 +37,13 @@ - + + + + + + + @@ -80,8 +91,8 @@ - - + + diff --git a/eng/pipelines/release-cli.yml b/eng/pipelines/release-cli.yml index b4ba9141b5..ce1b448f4a 100644 --- a/eng/pipelines/release-cli.yml +++ b/eng/pipelines/release-cli.yml @@ -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 @@ -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 diff --git a/eng/pipelines/templates/steps/build-msi.yml b/eng/pipelines/templates/steps/build-msi.yml index 2cc9cb42c7..ae50f418c8 100644 --- a/eng/pipelines/templates/steps/build-msi.yml +++ b/eng/pipelines/templates/steps/build-msi.yml @@ -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 }} @@ -28,4 +54,5 @@ steps: msbuildArguments: >- /p:RunWixToolsOutOfProc=true /p:Configuration=Release - /p:ProductVersion=$(MSI_VERSION) + $(MSI_PRODUCT_NAME_PARAM) + $(MSI_VERSION_PARAM)