From 5e5f18123f5162dbb5a6e7ed39559a7ab60e8229 Mon Sep 17 00:00:00 2001 From: Feng Zhou Date: Thu, 11 Mar 2021 11:24:14 +0800 Subject: [PATCH 1/3] add back msi test --- azure-pipelines.yml | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3809be44c13..15961baf66c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -180,11 +180,16 @@ jobs: displayName: Test Windows MSI dependsOn: BuildWindowsMSI - # condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'Manual', 'Schedule')) - condition: false + condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'Manual', 'Schedule')) pool: vmImage: 'vs2017-win2016' steps: + - task: DownloadPipelineArtifact@1 + displayName: 'Download Build Artifacts' + inputs: + TargetPath: '$(Build.ArtifactStagingDirectory)/metadata' + artifactName: metadata + - task: DownloadPipelineArtifact@1 displayName: 'Download Build Artifacts' inputs: @@ -196,16 +201,25 @@ jobs: inputs: targetType: inline script: | - $InstallArgs = @( - "/I" - '"$env:SYSTEM_ARTIFACTSDIRECTORY/msi/Microsoft Azure CLI.msi"' - "/norestart" - "/L*v" - ".\install_logs.txt" - ) - Start-Process "msiexec.exe" -ArgumentList $InstallArgs -Wait -NoNewWindow + # Elevate as Admin + if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { + $arguments = "& '" +$myinvocation.mycommand.definition + "'" + Start-Process powershell -Verb runAs -ArgumentList $arguments + Break + } + $pre_installed_version=az version --query '\"azure-cli\"' -o tsv + $to_be_installed_version=Get-Content $(System.ArtifactsDirectory)/metadata/version + if ($pre_installed_version -eq $to_be_installed_version){ + $reinstall_option="REINSTALL=ALL REINSTALLMODE=emus" + }else { + $reinstall_option="" + } + Start-Process "msiexec.exe" -ArgumentList "/i `"$env:SYSTEM_ARTIFACTSDIRECTORY\msi\Microsoft Azure CLI.msi`" $reinstall_option /q /norestart /l*v .\install_logs.txt" -Wait -NoNewWindow Get-Content .\install_logs.txt - + $installed_version=az version --query '\"azure-cli\"' -o tsv + if ($installed_version -ne $to_be_installed_version){ + Exit 1 + } az --version az self-test From 130c6cb40b85d5d3fab500eb781928c9e5bd96c2 Mon Sep 17 00:00:00 2001 From: Feng Zhou Date: Thu, 11 Mar 2021 11:24:40 +0800 Subject: [PATCH 2/3] remove aio dist-info --- azure-pipelines.yml | 1 + build_scripts/windows/scripts/build.cmd | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 15961baf66c..828311528e6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -207,6 +207,7 @@ jobs: Start-Process powershell -Verb runAs -ArgumentList $arguments Break } + az --version $pre_installed_version=az version --query '\"azure-cli\"' -o tsv $to_be_installed_version=Get-Content $(System.ArtifactsDirectory)/metadata/version if ($pre_installed_version -eq $to_be_installed_version){ diff --git a/build_scripts/windows/scripts/build.cmd b/build_scripts/windows/scripts/build.cmd index a819bf1d625..c5987943202 100644 --- a/build_scripts/windows/scripts/build.cmd +++ b/build_scripts/windows/scripts/build.cmd @@ -83,7 +83,7 @@ if not exist %PYTHON_DIR% ( popd ) set PYTHON_EXE=%PYTHON_DIR%\python.exe -%PYTHON_EXE% -m pip install --upgrade pip==21.0.1 +%PYTHON_EXE% -m pip install --upgrade pip==21.0.1 setuptools==52.0.0 robocopy %PYTHON_DIR% %BUILDING_DIR% /s /NFL /NDL @@ -146,10 +146,26 @@ for /f %%f in ('dir /b /s *.pyc') do ( ) popd +:: Remove __pycache__ +echo remove pycache for /d /r %BUILDING_DIR%\Lib\site-packages\pip %%d in (__pycache__) do ( if exist %%d rmdir /s /q "%%d" ) +:: Remove aio +echo remove aio +for /d /r %BUILDING_DIR%\Lib\site-packages\azure\mgmt %%d in (aio) do ( + if exist %%d rmdir /s /q "%%d" +) + +:: Remove dist-info +echo remove dist-info +pushd %BUILDING_DIR%\Lib\site-packages +for /d %%d in ("*.dist-info") do ( + if exist %%d rmdir /s /q "%%d" +) +popd + if %errorlevel% neq 0 goto ERROR ::ensure propagate_env_change.exe is available From c37201ccdb9f6bbe8d414475fa4b230c3c3700c7 Mon Sep 17 00:00:00 2001 From: Feng Zhou Date: Tue, 16 Mar 2021 21:39:44 +0800 Subject: [PATCH 3/3] address comments --- azure-pipelines.yml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 828311528e6..609a0141c14 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -201,24 +201,36 @@ jobs: inputs: targetType: inline script: | - # Elevate as Admin if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { + # Start another Powershell process as Admin and execute this script again $arguments = "& '" +$myinvocation.mycommand.definition + "'" Start-Process powershell -Verb runAs -ArgumentList $arguments + # Stop if the PowerShell is not run as Admin Break } + # The following are executed by elevated PowerShell az --version + + $InstallArgs = @( + "/i" + "`"$env:SYSTEM_ARTIFACTSDIRECTORY\msi\Microsoft Azure CLI.msi`"" + "/q" + "/norestart" + "/l*v" + ".\install_logs.txt" + ) $pre_installed_version=az version --query '\"azure-cli\"' -o tsv $to_be_installed_version=Get-Content $(System.ArtifactsDirectory)/metadata/version if ($pre_installed_version -eq $to_be_installed_version){ - $reinstall_option="REINSTALL=ALL REINSTALLMODE=emus" - }else { - $reinstall_option="" + # See https://docs.microsoft.com/windows/win32/msi/reinstallmode about options of REINSTALLMODE + $reinstall_option="REINSTALL=ALL REINSTALLMODE=emus" + $InstallArgs += $reinstall_option } - Start-Process "msiexec.exe" -ArgumentList "/i `"$env:SYSTEM_ARTIFACTSDIRECTORY\msi\Microsoft Azure CLI.msi`" $reinstall_option /q /norestart /l*v .\install_logs.txt" -Wait -NoNewWindow + Start-Process "msiexec.exe" -ArgumentList $InstallArgs -Wait -NoNewWindow Get-Content .\install_logs.txt $installed_version=az version --query '\"azure-cli\"' -o tsv if ($installed_version -ne $to_be_installed_version){ + echo "The MSI failed to install." Exit 1 } az --version