-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Packaging] Support Windows ZIP package #27911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
️✔️AzureCLI-FullTest
|
|
Hi @bebound, |
️✔️AzureCLI-BreakingChangeTest
|
|
Support Windows ZIP package |
|
|
||
| pushd %BUILDING_DIR% | ||
| %BUILDING_DIR%\python.exe %REPO_ROOT%\scripts\compact_aaz.py | ||
| if %errorlevel% neq 0 goto ERROR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check the error code of last command.
compact_aaz.py may fails because of #27923
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
azps.ps1 and az are not included in zip as they cause other problems. See #26682
| msbuild /t:rebuild /p:Configuration=Release /p:Platform=%ARCH% %REPO_ROOT%\build_scripts\windows\azure-cli.wixproj | ||
| ) else ( | ||
| echo Building ZIP... | ||
| ren %BUILDING_DIR% "Azure CLI" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Azure CLI as root folder of zip package.
PS: The MSI installation path is C:\Program Files\Microsoft SDKs\Azure\CLI2.
| ) else ( | ||
| echo Building ZIP... | ||
| ren %BUILDING_DIR% "Azure CLI" | ||
| "%ProgramFiles%\7-Zip\7z.exe" a -tzip "%OUTPUT_DIR%\Microsoft Azure CLI.zip" "%ZIP_DIR%" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compress-Archive and Expand-Archive take 5 and 10 minutes respectively. 7z is much faster, completing the task in just several seconds.
| robocopy %PYTHON_DIR% %BUILDING_DIR% /s /NFL /NDL | ||
|
|
||
| set CLI_SRC=%REPO_ROOT%\src | ||
| %BUILDING_DIR%\python.exe -m pip install --no-warn-script-location --force-reinstall pycparser==2.18 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pycparser==2.19 is installed later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| %BUILDING_DIR%\python.exe -m pip install --no-warn-script-location --requirement %CLI_SRC%\azure-cli\requirements.py3.windows.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also see #27196 (comment)
| REM Rename zip root folder to "Azure CLI" | ||
| ren %BUILDING_DIR% "Azure CLI" | ||
| REM Use LZMA compression to reduce the size of the zip file. | ||
| "%ProgramFiles%\7-Zip\7z.exe" a -tzip -m0=LZMA "%OUTPUT_DIR%\Microsoft Azure CLI.zip" "%ZIP_DIR%" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right.
According to the doc, -m0 should only works in 7z and I should use -mm.
However, it works.
I've created a bug report for 7z: https://sourceforge.net/p/sevenzip/bugs/2441/
|
Windows File Explorer doesn't support extracting This ZIP file is created by If you use the Windows's built-in "Send to -> Compressed (zipped) folder" to create the ZIP file: You can see it uses You can also see this from 7-Zip File Manager: Reference: https://stackoverflow.com/questions/6896487/how-to-determine-compression-method-of-a-zip-rar-file |
|
|
Well spotted! |
| mkdir %ARTIFACTS_DIR% | ||
| set TEMP_SCRATCH_FOLDER=%ARTIFACTS_DIR%\cli_scratch | ||
| set BUILDING_DIR=%ARTIFACTS_DIR%\cli | ||
| set ZIP_ROOT_FOLDER="AzureCLI" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be the first time we introduce the term AzureCLI. Other alternatives can be azure-cli, az.
However, I downloaded several other Microsoft-owned apps, like
- PowerShell: https://github.com/PowerShell/PowerShell/releases/download/v7.4.1/PowerShell-7.4.1-win-x64.zip from https://github.com/PowerShell/PowerShell/releases/tag/v7.4.1
- VS Code: https://code.visualstudio.com/sha/download?build=stable&os=win32-x64-archive from https://code.visualstudio.com/Download
- PsTools: https://download.sysinternals.com/files/PSTools.zip from https://learn.microsoft.com/en-us/sysinternals/downloads/pstools
All put their content in the root folder.
| copy %REPO_ROOT%\build_scripts\windows\scripts\azps.ps1 %BUILDING_DIR%\wbin\ | ||
| copy %REPO_ROOT%\build_scripts\windows\scripts\az %BUILDING_DIR%\wbin\ | ||
| ) else ( | ||
| copy %REPO_ROOT%\build_scripts\windows\scripts\az_zip.cmd %BUILDING_DIR%\wbin\az.cmd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other Microsoft-owned apps mentioned in #27911 (comment) put their executables such as Code.exe, pwsh.exe under the root folder. Perhaps we can do the same and put az.cmd under the root folder?
But this approach has its own problem: adding Azure CLI's folder to PATH will also put python.exe under PATH. If a user accidentally executes python.exe, that may corrupt Azure CLI's virtual environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to maintain the current structure to avoid adding other executables into PATH.
PS: Other CLI tools also place their executables to dedicated folder. For example: C:\Program Files\Docker\Docker\resources\bin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we use wbin, instead of bin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. The explanation is right in the comment:
azure-cli/build_scripts/windows/scripts/build.cmd
Lines 147 to 148 in 04d82da
| echo Creating the wbin (Windows binaries) folder that will be added to the path... | |
| mkdir %BUILDING_DIR%\wbin |
It was added by #2655.
I initially thought it means
A Unicode version with the letter "W" used to indicate "wide"
-- https://learn.microsoft.com/en-us/windows/win32/intl/unicode-in-the-windows-api
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this package is for Windows, w seems redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other Microsoft-owned apps mentioned in #27911 (comment) put their executables such as
Code.exe,pwsh.exeunder the root folder. Perhaps we can do the same and putaz.cmdunder the root folder?But this approach has its own problem: adding Azure CLI's folder to
PATHwill also putpython.exeunderPATH. If a user accidentally executespython.exe, that may corrupt Azure CLI's virtual environment.
Adding python in the path could also create instability if the platform (for example a custom build agent) is using python for other purposes.
I think that wbin will be confusing and the information it adds is not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dcaro I can change the folder to bin in zip package.
Should we also do this in MSI? We never mention wbin in doc, and it's automatically added into PATH during MSI installation. This change should not affect users unless they use full path to run az.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's leave the folder name in the msi as is for now, as you mention, it is automatically added to path and transparent to users.
| copy %REPO_ROOT%\build_scripts\windows\scripts\azps.ps1 %BUILDING_DIR%\wbin\ | ||
| copy %REPO_ROOT%\build_scripts\windows\scripts\az %BUILDING_DIR%\wbin\ | ||
| if "%TARGET%"=="msi" ( | ||
| REM Creating the wbin (Windows binaries) folder that will be added to the path... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I use echo instead of REM, the (Windows binaries) folder will be parsed and folder was unexpected at this time. error will be raised. It seems there are some special rules when parentheses block is executed.
Repro script:
echo () ok
if 'kk'=='kk' (
echo () ok2
)() ok
ok2 was unexpected at this time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you truly need to use echo, you may quote the sentence:
echo "Creating the wbin (Windows binaries) folder that will be added to the path..."There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. (Generally, echo is able to print multiple word without the quote: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/echo)
In this instance, since the line functions more as a comment, so I changed it to REM.
|
Downloaded from https://azcliprod.blob.core.windows.net/zip/azure-cli-2.57.0-x64.zip and the ZIP package works like a charm! 🎉 |
|
Another great benefit of the ZIP package is that it allows much easier edge build release. Currently, in order to install an MSI edge build, I have to
But with ZIP, I can simply extract it and run |





Description
Close #22462
Release zip package so that CLi can be used without admin privilege.
Difference between MSI build
az.cmdentry scriptwbintobinPackage size
The uncompressed folder is 283MB
zip with
deflatealgorithm: 90MBzip with
LZMAalgorithm: 77MB (Windows File Explorer does not support it)MSI is packed to a cab file and zipped with
LZXalgorighm: 67MB.If I compressed it to 7z, it's only 37MB, which is due to the Solid compression. If I disable solid compression, the size become 72MB.
Unfortunately, zip does not support solid compression. Since it can be opened without installing any software, let's keep using zip.
7z is much faster than
Compress-ArchiveandExpand-ArchiveCompress-ArchiveandExpand-Archivetake 5 and 10 minutes respectively.7zis much faster, completing the task in just several seconds.Doc is MicrosoftDocs/azure-docs-cli#4045