winget-cli
winget-cli copied to clipboard
Document Exit Codes
Brief description of your issue
Please document the exit codes so WinGet can be used in batch files.
If you are referring to exit codes coming from installers, they could be nearly anything. The exit codes from MSIX, and MSI installers are well documented. For EXE installers, it depends on the publisher when they package their application. We do have an ability to map expected return codes from EXE installers to more standardized error codes in the manifest.
- #1278
Is this what you are referring to?
I think they mean the exit codes returned by winget itself, not the installers, i.e. the ones defined in AppInstallerErrors.h Something like "0x8A150008 means that downloading the installer failed; 0x8A150109 means that the installer needs a reboot to finish; etc." So somebody could call winget in a script, and handle each error differently.
@lechacon exactly
+1
To put a little more meat on this problem - it's not uncommon that a bit of a script might have a goal like: "Ensure that such&such a package is installed and at the latest version". Right now, if you want to validate that the installation happened, you have to check your exit code against everything that the installer might do (which can often be summed up by 'if it returns 0, it succeeded') plus everything that WinGet might do. If WinGet decides the package is already current and up-to-date, it exits with APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE, so an install script has to check not just against zero, but also against -1978335189.
PR https://github.com/microsoft/winget-cli/pull/3202 added a doc listing exit codes returned by WinGet
https://github.com/microsoft/winget-cli/blob/master/doc/windows/package-manager/winget/returnCodes.md
cc @denelon if this needs to be closed
https://github.com/microsoft/winget-cli/blob/master/doc/windows/package-manager/winget/returnCodes.md