-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[Packaging] Support Windows ZIP package #27911
Changes from 3 commits
452a3dc
181d34b
2125e39
74aa576
fda9040
33b2cf7
79e3c18
ef1f743
d926724
72667ad
deb94ac
7ed5497
63207d3
6fa7aa4
0956882
52552df
3e6f1b5
dd0f8bc
95264cd
ac32b2d
6fb6c8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
:: | ||
:: Microsoft Azure CLI - Windows Installer - Author file components script | ||
:: Copyright (C) Microsoft Corporation. All Rights Reserved. | ||
:: | ||
|
||
@IF EXIST "%~dp0\..\python.exe" ( | ||
SET AZ_INSTALLER=ZIP | ||
"%~dp0\..\python.exe" -IBm azure.cli %* | ||
) ELSE ( | ||
echo Failed to load python executable. | ||
exit /b 1 | ||
) |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -13,10 +13,15 @@ if "%CLI_VERSION%"=="" ( | |||||
echo Please set the CLI_VERSION environment variable, e.g. 2.0.13 | ||||||
goto ERROR | ||||||
) | ||||||
|
||||||
@REM ARCH can be x86 or x64 | ||||||
if "%ARCH%"=="" ( | ||||||
set ARCH=x86 | ||||||
) | ||||||
@REM TARGET can be msi or zip | ||||||
if "%TARGET%"=="" ( | ||||||
set TARGET=msi | ||||||
) | ||||||
|
||||||
if "%ARCH%"=="x86" ( | ||||||
set PYTHON_ARCH=win32 | ||||||
) else if "%ARCH%"=="x64" ( | ||||||
|
@@ -43,6 +48,7 @@ set ARTIFACTS_DIR=%~dp0..\artifacts | |||||
mkdir %ARTIFACTS_DIR% | ||||||
set TEMP_SCRATCH_FOLDER=%ARTIFACTS_DIR%\cli_scratch | ||||||
set BUILDING_DIR=%ARTIFACTS_DIR%\cli | ||||||
set ZIP_DIR=%ARTIFACTS_DIR%\Azure CLI | ||||||
set WIX_DIR=%ARTIFACTS_DIR%\wix | ||||||
set PYTHON_DIR=%ARTIFACTS_DIR%\Python | ||||||
|
||||||
|
@@ -71,20 +77,22 @@ if exist %REPO_ROOT%\privates ( | |||||
copy %REPO_ROOT%\privates\*.whl %TEMP_SCRATCH_FOLDER% | ||||||
) | ||||||
|
||||||
REM ensure wix is available | ||||||
if exist %WIX_DIR% ( | ||||||
echo Using existing Wix at %WIX_DIR% | ||||||
) | ||||||
if not exist %WIX_DIR% ( | ||||||
mkdir %WIX_DIR% | ||||||
pushd %WIX_DIR% | ||||||
echo Downloading Wix. | ||||||
curl --output wix-archive.zip %WIX_DOWNLOAD_URL% | ||||||
unzip wix-archive.zip | ||||||
if %errorlevel% neq 0 goto ERROR | ||||||
del wix-archive.zip | ||||||
echo Wix downloaded and extracted successfully. | ||||||
popd | ||||||
if "%TARGET%" == 'msi' ( | ||||||
REM ensure wix is available | ||||||
if exist %WIX_DIR% ( | ||||||
echo Using existing Wix at %WIX_DIR% | ||||||
) | ||||||
if not exist %WIX_DIR% ( | ||||||
mkdir %WIX_DIR% | ||||||
pushd %WIX_DIR% | ||||||
echo Downloading Wix. | ||||||
curl --output wix-archive.zip %WIX_DOWNLOAD_URL% | ||||||
unzip wix-archive.zip | ||||||
if %errorlevel% neq 0 goto ERROR | ||||||
del wix-archive.zip | ||||||
echo Wix downloaded and extracted successfully. | ||||||
popd | ||||||
) | ||||||
) | ||||||
|
||||||
REM ensure Python is available | ||||||
|
@@ -122,7 +130,6 @@ set PYTHON_EXE=%PYTHON_DIR%\python.exe | |||||
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 commentThe 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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Also see #27196 (comment) |
||||||
for %%a in (%CLI_SRC%\azure-cli %CLI_SRC%\azure-cli-core %CLI_SRC%\azure-cli-telemetry) do ( | ||||||
pushd %%a | ||||||
%BUILDING_DIR%\python.exe -m pip install --no-warn-script-location --no-cache-dir --no-deps . | ||||||
|
@@ -137,18 +144,25 @@ if %errorlevel% neq 0 goto ERROR | |||||
|
||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Check the error code of last command. |
||||||
%BUILDING_DIR%\python.exe %~dp0\patch_models_v2.py | ||||||
if %errorlevel% neq 0 goto ERROR | ||||||
%BUILDING_DIR%\python.exe %REPO_ROOT%\scripts\trim_sdk.py | ||||||
if %errorlevel% neq 0 goto ERROR | ||||||
popd | ||||||
|
||||||
REM Remove pywin32 help file to reduce size. | ||||||
del %BUILDING_DIR%\Lib\site-packages\PyWin32.chm | ||||||
|
||||||
echo Creating the wbin (Windows binaries) folder that will be added to the path... | ||||||
mkdir %BUILDING_DIR%\wbin | ||||||
copy %REPO_ROOT%\build_scripts\windows\scripts\az.cmd %BUILDING_DIR%\wbin\ | ||||||
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" ( | ||||||
copy %REPO_ROOT%\build_scripts\windows\scripts\az.cmd %BUILDING_DIR%\wbin\ | ||||||
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 commentThe 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 commentThe 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 But this approach has its own problem: adding Azure CLI's folder to There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we use There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
It was added by #2655. I initially thought it means
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, this package is for Windows, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dcaro I can change the folder to There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||
) | ||||||
if %errorlevel% neq 0 goto ERROR | ||||||
copy %REPO_ROOT%\build_scripts\windows\resources\CLI_LICENSE.rtf %BUILDING_DIR% | ||||||
copy %REPO_ROOT%\build_scripts\windows\resources\ThirdPartyNotices.txt %BUILDING_DIR% | ||||||
|
@@ -193,14 +207,19 @@ for /d %%d in ("azure*.dist-info") do ( | |||||
) | ||||||
popd | ||||||
|
||||||
if %errorlevel% neq 0 goto ERROR | ||||||
|
||||||
echo Building MSI... | ||||||
msbuild /t:rebuild /p:Configuration=Release /p:Platform=%ARCH% %REPO_ROOT%\build_scripts\windows\azure-cli.wixproj | ||||||
if "%TARGET%"=="msi" ( | ||||||
echo Building MSI... | ||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
powershell Compress-Archive -Path '%ZIP_DIR%' -DestinationPath %OUTPUT_DIR%\azure-cli-%CLI_VERSION%.zip | ||||||
) | ||||||
|
||||||
if %errorlevel% neq 0 goto ERROR | ||||||
|
||||||
echo %OUTPUT_DIR% | ||||||
echo Output Dir: %OUTPUT_DIR% | ||||||
|
||||||
goto END | ||||||
|
||||||
|
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.
A folder name with space (
Azure CLI
) causes lots of trouble when the full path is being invoked from PowerShell.For example, the MSI installs the Azure CLI executable at
C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin\az.cmd
.It can't be directly executed because of the space in the path:
If we quote it, PowerShell treats it as a string and echoes it:
The correct way to invoke the executable with its full path is:
Of course, we don't want such complex way of invoking
az.cmd
.I suggest either
Azure CLI
toazure-cli
to align with other packages, such as PyPI, DEB, RPM, or