winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

How-to guide for installing Microsoft.DesktopAppInstaller non-interactively

Open cdhunt opened this issue 1 year ago • 9 comments

Brief description of your issue

I would like to bootstrap WinGet and several WinGet packages on new Win10 systems.

What is the correct approach that handles dependencies appropriately and does not require user interaction?

This is what I'm using and it will break as soon as the dependency versions change. ~~It's also not possible to install MS Store applications because of a interactive license acceptance prompt that does not honor the --accept-source-agreements argument.~~

cdhunt avatar Aug 09 '22 13:08 cdhunt

#2436 helps.

cdhunt avatar Aug 09 '22 16:08 cdhunt

I think this may also be related to #401

Trenly avatar Aug 09 '22 16:08 Trenly

@cdhunt there is also an "--accept-package-agreements" argument to handle those.

denelon avatar Aug 09 '22 16:08 denelon

I added both and it still prompts on the first install unless you visit the MS Store interactively first.

cdhunt avatar Aug 09 '22 16:08 cdhunt

Can you share a screen recording or something to help reproduce that? You should be able to:

winget install <package> -s msstore --accept-source-agreements --accept-package-agreements

without having to interactively accept an agreement prompt. The agreements still get displayed, but you shouldn't have to interact with them.

winget install 9N0DX20HK701 --accept-package-agreements --accept-source-agreements
Found Windows Terminal [9N0DX20HK701] Version Unknown
This package is provided through Microsoft Store. winget may need to acquire the package from Microsoft Store on behalf of the current user.
Version: Unknown
Publisher: Microsoft Corporation
Publisher Url: https://github.com/microsoft/terminal
Publisher Support Url: https://github.com/microsoft/terminal/issues/new
Description:
  The Windows Terminal is a modern, fast, efficient, powerful, and productive terminal application for users of command-line tools and shells like Command Prompt, PowerShell, and WSL. Its main features include multiple tabs, panes, Unicode and UTF-8 character support, a GPU accelerated text rendering engine, and custom themes, styles, and configurations.

  This is an open source project and we welcome community participation. To participate please visit https://github.com/microsoft/terminal
License: ms-windows-store://pdp/?ProductId=9N0DX20HK701
Privacy Url: go.microsoft.com/fwlink/?LinkID=521839
Copyright: Copyright (c) Microsoft Corporation
Agreements:
Category: Developer tools
Pricing: Free
Free Trial: No
Terms of Transaction: https://aka.ms/microsoft-store-terms-of-transaction
Seizure Warning: https://aka.ms/microsoft-store-seizure-warning
Store License Terms: https://aka.ms/microsoft-store-license


Verifying/Requesting package acquisition...
Verifying/Requesting package acquisition success
Starting package install...
  ██████████████████████████████  100%
Successfully installed

Note: This assumes you are running at least the stable version of 1.3 or newer. The bug requiring MSA authentication to the Windows Store was fixed in a 1.3 preview build.

denelon avatar Aug 09 '22 16:08 denelon

I will re-test. When I encountered this it was 1.2.

cdhunt avatar Aug 09 '22 17:08 cdhunt

TLDR

I'm running into a similar issue using winget (v1.3.2091) on a clean install of Windows 11 Enterprise (v10.0.22000 N/A Build 22000). It looks like it is missing the Microsoft.Winget.Source dependency. Anyone know where to get it from? I have tried restarting the VM after installing WinGet and that didn't change anything.

Details

This is the first command I execute after a clean install on a Windows 11 Enterprise VM on Azure, right after running the @cdhunt script: winget install --id 'Notepad++.Notepad++' --exact --scope machine --silent --accept-package-agreements --accept-source-agreements --log 'c:\install\install-notepad.progress.log' --verbose-logs;

Console Output:

The msstore source requires that you view the following agreements before using. Terms of Transaction: https://aka.ms/microsoft-store-terms-of-transaction The source requires the current machine's 2-letter geographic region to be sent to the backend service to function properly (ex. "US").

Failed when searching source: winget An unexpected error occurred while executing the command: 0x8a15000f : Data required by the source is missing

Digging into the log in ..\LocalState\DiagOutputDir and I found this:

2022-08-26 18:54:14.764 [FAIL] D:\a_work\1\s\external\pkg\src\AppInstallerCommonCore\Deployment.cpp(54)\WindowsPackageManager.dll!00007FFF66388674: (caller: 00007FFF66388D73) Exception(1) tid(19e8) 80073D19 An error occurred because a user was logged off.

Msg:[Operation failed: Deployment Add operation with target volume C: on Package Microsoft.Winget.Source_2022.826.1855.514_neutral__8wekyb3d8bbwe from: failed with error 0x80073D19. See http://go.microsoft.com/fwlink/?LinkId=235160 for help diagnosing app deployment issues.]

Msg: [D:\a_work\1\s\external\pkg\src\AppInstallerCommonCore\Deployment.cpp(54)\WindowsPackageManager.dll!00007FFF66 388674: (caller: 00007FFF66388D73) Exception(1) tid(19e8) 80073D19 An error occurred because a user was logged off.

Msg:[Operation failed: Deployment Add operation with target volume C: on Package Microsoft.Winget.Source_2022.826.1855.514_neutral__8wekyb3d8bbwe from: failed with error 0x80073D19. See http://go.microsoft.com/fwlink/?LinkId=235160 for help diagnosing app deployment issues.] ]

Then later in the log I see this error:

2022-08-26 18:54:17.258 [FAIL] D:\a_work\1\s\external\pkg\src\AppInstallerRepositoryCore\Microsoft\PreIndexedPackageSo urceFactory.cpp(301)\WindowsPackageManager.dll!00007FFF663F235E: (caller: 00007FFF663F1142) LogHr(2) tid(19e8) 80071130 Fast Cache data not found.

What is odd is that this same exact response doesn't happen the second time. When I retry the same command line I receive the following Console Output now:

Failed when searching source: winget An unexpected error occurred while executing the command: 0x8a15000f : Data required by the source is missing

No packages were found among the working sources.

But the errors in the log look nearly identical:

2022-08-26 20:56:00.245 [FAIL] D:\a_work\1\s\external\pkg\src\AppInstallerCommonCore\Deployment.cpp(54)\WindowsPackageManager.dll!00007FFE98498674: (caller: 00007FFE98498D73) Exception(1) tid(6fc) 80073D19 An error occurred because a user was logged off.

Msg:[Operation failed: Deployment Add operation with target volume C: on Package Microsoft.Winget.Source_2022.826.2037.64_neutral__8wekyb3d8bbwe from: failed with error 0x80073D19. See http://go.microsoft.com/fwlink/?LinkId=235160 for help diagnosing app deployment issues.]

2022-08-26 20:56:00.253 [FAIL] D:\a_work\1\s\external\pkg\src\AppInstallerRepositoryCore\RepositorySource.cpp(53)\Wind owsPackageManager.dll!00007FFE98612C41: (caller: 00007FFE984F2E5B) LogHr(1) tid(6fc) 80073D19 An error occurred because a user was logged off.

Msg:[D:\a_work\1\s\external\pkg\src\AppInstallerCommonCore\Deployment.cpp(54)\WindowsPackageManager.dll!00007FFE98 498674: (caller: 00007FFE98498D73) Exception(1) tid(6fc) 80073D19 An error occurred because a user was logged off.

Msg:[Operation failed: Deployment Add operation with target volume C: on Package Microsoft.Winget.Source_2022.826.2037.64_neutral__8wekyb3d8bbwe from: failed with error 0x80073D19. See http://go.microsoft.com/fwlink/?LinkId=235160 for help diagnosing app deployment issues.] ]

And later in the log:

2022-08-26 20:56:02.664 [FAIL] D:\a_work\1\s\external\pkg\src\AppInstallerRepositoryCore\Microsoft\PreIndexedPackageSo urceFactory.cpp(301)\WindowsPackageManager.dll!00007FFE9850235E: (caller: 00007FFE98501142) LogHr(2) tid(6fc) 80071130 Fast Cache data not found.

Notes

  • The install-notepad.progress.log file wasn't created: bug or expected?
  • Once I interactively log-in to the VM the marketplace loads winget, as well as many other apps, so I cannot do that. This makes running commands on the box a bit more difficult. So I executed the above command using the Azure run-command under a PSSession with the credentials for the admin user that Azure setup at VM creation (not the system user).

bretboss avatar Aug 26 '22 21:08 bretboss

I found where to get it from in the WinGet log file. Looking at the logs it looks like it downloads it but cannot install it. I installed it manually and then was able to install the winget Notepad++ package.

I installed the Microsoft.Winget.Source app with the following:

Invoke-WebRequest 'https://cdn.winget.microsoft.com/cache/source.msix' -OutFile 'c:\downloads\Microsoft.Winget.Source.msix' -UseBasicParsing

Push-Location 'c:\downloads';
Add-AppxPackage -Path 'Microsoft.Winget.Source.msix';
Pop-Location;

Note: These results are preliminary! When I went back to look at what WinGet packages were installed I saw more than what I had installed. So I don't know if Windows 11 fixed this for me so it could do its own installs. Looks like I'll need to spin up another VM in Azure to test this on.

bretboss avatar Aug 26 '22 22:08 bretboss

When I went back to look at what WinGet packages were installed I saw more than what I had installed.

winget list will show all apps installed on your PC regardless of where it came from. What you're seeing is likely the pre-installed apps that come built-in to Windows.

Keep your eyes on https://github.com/microsoft/winget-cli/issues/1155 (and maybe https://github.com/microsoft/winget-cli/issues/964) which is tracking this.

ItzLevvie avatar Aug 26 '22 23:08 ItzLevvie

The Repair-WinGetPackageManager cmdlet in the Microsoft.WinGet.Client PowerShell Module does much of the work to handle dependencies, but Microsoft.UI.Xaml is still not handled in the most optimal way. We're looking at some options here to see if we can improve the situation without needing to download and decompress the dependency.

We've also been looking to update the dependency to Microsoft.UI.Xaml 2.8 from 2.7 in WinGet:

  • https://github.com/microsoft/winget-cli/issues/3380

denelon avatar Jun 28 '23 19:06 denelon

We've provided documentation for installing the App Installer and its dependencies over at Microsoft Learn.

denelon avatar Mar 06 '24 16:03 denelon