Repository navigation
Support elevated azd update for machine-wide MSI installations - #10696
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 25 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🔵 Needs a closer look
Elevated MSI recovery and Windows process-lifecycle changes retain unresolved correctness risks that require human validation on Windows.
4 open issues
What changed in this PR
Extends azd update to support registered machine-wide Windows MSI installations from an elevated terminal, preserving machine scope and custom installation directories.
Changes:
- Adds installation-scope validation and signed, pinned stable MSI updates.
- Adds MSI outcome handling, restart-required messaging, and deferred backup cleanup.
- Updates Windows process execution, regression tests, and documentation.
| File | Description |
|---|---|
cli/installer/README.md |
Documents administrator-managed machine-wide updates. |
cli/azd/pkg/update/msi_windows.go |
Implements scope detection and machine MSI updates. |
cli/azd/pkg/update/msi_windows_test.go |
Tests validation, update outcomes, backups, and locking. |
cli/azd/pkg/update/msi_unix.go |
Provides unsupported-platform MSI stubs. |
cli/azd/pkg/update/msi_cleanup_windows.go |
Adds detached, bounded backup cleanup. |
cli/azd/pkg/update/msi_cleanup_windows_test.go |
Tests cleanup retries and retained diagnostics. |
cli/azd/pkg/update/manager.go |
Moves Windows-specific update logic into platform files. |
cli/azd/pkg/update/errors.go |
Adds the restart-required sentinel error. |
cli/azd/pkg/exec/util_test.go |
Tests literal arguments without shell processing. |
cli/azd/pkg/exec/runargs.go |
Tracks explicit shell selection. |
cli/azd/pkg/exec/runargs_test.go |
Tests shell-selection defaults and overrides. |
cli/azd/pkg/exec/command_runner.go |
Honors explicit direct execution on Windows. |
cli/azd/docs/design/azd-update.md |
Describes machine-wide update lifecycle and restrictions. |
cli/azd/cmd/update.go |
Reports restart-required updates separately from failures. |
cli/azd/cmd/update_test.go |
Tests normal and restart-required completion messages. |
cli/azd/.vscode/cspell.yaml |
Allows installer-specific terminology. |
Review effort: Max
5e90868 to
3c9b95b
Compare
cab621f to
2d56542
Compare
azd update rejected every Windows installation outside the default per-user directory, including ALLUSERS=1 installs, even from an elevated terminal. Administrators had to run each new MSI by hand. Install scope now comes from the InstallDir value that an ALLUSERS=1 install writes under HKLM\SOFTWARE\Microsoft\Azure Dev CLI, so custom machine directories are recognized and preserved. The default per-user directory is still accepted; other locations fail with a suggestion. Machine-wide updates require an already elevated x64 process on a stable-to-stable update; azd never prompts for UAC, and a non-elevated terminal gets an error suggesting the exact command to run as administrator. Channel changes still need the MSI installer. Winget and Chocolatey installs are unchanged. For a machine install, azd downloads the pinned stable MSI into the installation directory (inheriting its ACL), verifies its Authenticode signature, and runs msiexec /qn /norestart with ALLUSERS=1 and the existing INSTALLDIR, uncancelable and serialized by a global mutex. Rollback follows the MSI transaction: failures before commit restore the backed-up executable, exit code 3010 reports a required restart without rolling back, and a committed install that fails verification keeps the installed state and backup with repair guidance. MSI logs are kept on every non-success outcome. The old backup cleanup always failed silently because the backup is the running image, leaking one azd.exe per update. A detached system PowerShell helper now retries the delete for up to a minute after azd exits and writes failures to cleanup.log, with manual guidance if the helper cannot start. exec.RunArgs.WithShell(false) now forces a direct process start on Windows so msiexec and signature-check arguments are passed verbatim. Scope resolution, validation inputs, hashes, and cleanup progress are logged under --debug. Docs and the installer README describe the flow. Copilot-Session: 056fdf5f-b33a-4ee1-b271-81336506589e
Supply MSI-compatible native quoting so INSTALLDIR="value" reaches Windows Installer without Go quoting the entire property assignment. Add coverage through the real MSI parser using a nonexistent package, without modifying installed products. Copilot-Session: 056fdf5f-b33a-4ee1-b271-81336506589e
Use the existing terminal command styling without literal Markdown backticks. Copilot-Session: 056fdf5f-b33a-4ee1-b271-81336506589e
2d56542 to
8ace1ff
Compare
Retain the registered machine path for scope matching, but allow a valid default per-user installation to update when an unrelated machine directory is inaccessible. Preserve machine scope for matching registrations and propagate resolution errors for unsupported locations. Copilot-Session: 056fdf5f-b33a-4ee1-b271-81336506589e
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
|
Mt.matutum development boolibooli (@peaceray) MaPildev (talk) 01:55, 8 November 2026 (UTC) |



Fixes #10682
This PR lets
azd updateupdate a machine-wideALLUSERS=1MSI installation from an elevated terminal, including custom install directories. Per-user installs keep usinginstall-azd.ps1; winget and Chocolatey installs are unchanged.azd update(non-admin):azd update(admin):Issue
azd updateonly accepted the default per-user directory under%LOCALAPPDATA%. A machine-wide install was rejected by the location check before any update ran, so an elevated terminal made no difference and administrators had to run each new MSI by hand.Scope detection and rules
A machine-wide install is recognized when the running executable lives in the
InstallDirregistered underHKLM\SOFTWARE\Microsoft\Azure Dev CLIby anALLUSERS=1install. That same path is passed back asINSTALLDIR, so custom directories are preserved.azd update --channel stablefrom a terminal opened with "Run as administrator". Channel changes still require the MSI installer.Machine-wide update flow
The pinned stable MSI is downloaded into the installation directory, inherits its ACL, and has its Authenticode signature verified before the executable is modified. Signature verification uses literal paths so custom directories containing brackets work.
msiexec /i <msi> /qn /norestart ALLUSERS=1 INSTALLDIR="<existing dir>"with verbose logging, cancellation suppressed, and a global mutex preventing concurrent updates of the same install.3010reports a required restart without rolling back. A committed install that fails verification keeps the installed state and backup with repair guidance. MSI logs are kept on every non-success outcome.Backup cleanup
The old cleanup silently failed because the backup is the running image, leaking one
azd.exeper update under%TEMP%. A detached PowerShell helper now retries deletion for up to a minute after azd exits, logs failures tocleanup.log, and never schedules reboot-time operations. Routine cleanup stays in debug logs; failures to start the helper print manual cleanup guidance.Other changes
exec.RunArgs.WithShell(false)now forces a direct process start on Windows. The MSI invocation also supplies an explicit Windows command line because msiexec does not follow Go's default argument-quoting rules. Quoting theINSTALLDIRvalue rather than the whole assignment avoids error1639and the Windows Installer usage dialog for directories containing spaces.Scope resolution, validation inputs, hashes, and cleanup progress are logged under
--debug. The design doc and installer README describe the new flow.Testing
Focused checks cover update outcomes, error guidance, literal signature paths, and native MSI command-line parsing. The ADO error-mapping check explicitly excludes the restart-required sentinel because the update command handles it as success.
1.37.0underC:\Program Files\Azure Dev CLIto the signed1.37.1release completed with MSI exit code0. The executable hash changed and a subsequentazd versionreported1.37.1.