Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 33 additions & 6 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -196,16 +201,38 @@ jobs:
inputs:
targetType: inline
script: |
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"'
"/i"
"`"$env:SYSTEM_ARTIFACTSDIRECTORY\msi\Microsoft Azure CLI.msi`""
"/q"
"/norestart"
"/L*v"
"/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){
# See https://docs.microsoft.com/windows/win32/msi/reinstallmode about options of REINSTALLMODE
$reinstall_option="REINSTALL=ALL REINSTALLMODE=emus"
$InstallArgs += $reinstall_option
}
Comment on lines +224 to +228
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ADO agent has a pre-installed Azure CLI MSI, so this job tries to "reinstall" with the artifact MSI. If the artifact MSI has the same version as the pre-installed Azure CLI, L226 adds REINSTALL=ALL REINSTALLMODE=emus.

If I run the msiexec.exe command locally (with or without /q):

msiexec.exe /i "Microsoft Azure CLI.msi" REINSTALL=ALL REINSTALLMODE=emus

it succeeds very fast but doesn't install anything, so the "reinstall" actually never works.

I guess it is because the artifact MSI is actually a different product as the pre-installed one, so it has nothing to "reinstall". I am not sure if this is related to Product.Id being *:

After removing REINSTALL=ALL REINSTALLMODE=emus, the artifact MSI can install successfully, but is installed side-by-side with the pre-installed one.

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
az self-test

Expand Down
18 changes: 17 additions & 1 deletion build_scripts/windows/scripts/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down