microsoft / winget-cli

WinGet is the Windows Package Manager. This project includes a CLI (Command Line Interface), PowerShell modules, and a COM (Component Object Model) API (Application Programming Interface).
https://learn.microsoft.com/windows/package-manager/
MIT License
23.06k stars 1.43k forks source link

Accept EULA remote doesn't work or isn't well documented #3122

Open TripleNico opened 1 year ago

TripleNico commented 1 year ago

Brief description of your issue

I rolled out Winget to our domain machines and i'm facing an issue where i cant install a package due to the fact the msstore agreement terms aren't accepted.

The exact error:

...> winget upgrade "Adobe Acrobat (64-bit)" --silent --accept-source-agreements --accept-source-agreements

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

Steps to reproduce

Let me walk you through the steps i've taken.

First step, install Winget on remote computers

Invoke-Command -ComputerName $Computername -ScriptBlock {
    $Hostname = Hostname

    #Install Winget and extra's
    Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.3 -OutFile C:\temp\microsoft.ui.xaml.2.7.3.zip   
    Expand-Archive -Path "C:\temp\microsoft.ui.xaml.2.7.3.zip" -DestinationPath "C:\temp\microsoft.ui.xaml.2.7.3"
    Add-AppxPackage C:\temp\microsoft.ui.xaml.2.7.3\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx

    Invoke-WebRequest -Uri https://github.com/microsoft/winget-cli/releases/download/v1.3.2691/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle -OutFile C:\temp\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
    Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile C:\temp\Microsoft.VCLibs.x64.14.00.Desktop.appx
    Add-AppxPackage C:\temp\Microsoft.VCLibs.x64.14.00.Desktop.appx
    Add-AppxPackage C:\temp\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle

    #Clean-up
    Remove-Item "C:\temp\microsoft.ui.xaml.2.7.3" -Recurse
    Remove-Item "C:\temp\microsoft.ui.xaml.2.7.3.zip"        
    Remove-Item "C:\temp\Microsoft.VCLibs.x64.14.00.Desktop.appx"
    Remove-Item "C:\temp\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"

    #Show version if succes
    Write-Host "$Hostname - $(winget -v)"
}

This installs version v1.3.2691 on all computers.

Expected behavior

I excepted so see that is would upgrade adobe reader.

Actual behavior

Next step was trying to upgrade something like Adobe Reader. I first searched using Winget search adobe for the right package name which led me to:

winget upgrade "Adobe Acrobat (64-bit)" --silent

But this resulted in the error:

...> winget upgrade "Adobe Acrobat (64-bit)" --silent

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").

Do you agree to all the source agreements terms?
[Y] Yes  [N] No: An unexpected error occurred while executing the command:
0x8a150042 : Error reading input in prompt

So after some googling i found out i can add the --accept-source-agreements and --accept-package-agreements parameters to accept it remotely. Like this topic describes: #1536 but as you can see above in the first code block this still results in that error.

Next step was asking ChatGPT since i didn't find any other hint on google. ChatGPT suggested running:

Start-Process -FilePath "winget" -ArgumentList "features", "-a" -WindowStyle Hidden -Wait

But this didn't change anything.

Back to google and i found out that there is also an ADMX file for GPO control. Imported that, enabled Winget AND set the trusted sources to msstore and winget but again without success.

Finally I tried reinstalling everything and also source reset but all with no luck.

Am i missing something here? Hopefully someone could pinpoint the problem.

Thanks!

Environment

Windows Package Manager v1.4.10173
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.19044.2728
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.19.10173.0

Logs: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir

User Settings: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json

Links
---------------------------------------------------------------------------
Privacy Statement   https://aka.ms/winget-privacy
License Agreement   https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage            https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale
yao-msft commented 1 year ago

Winget has 2 default sources: msstore (the Microsoft Store source) and winget (community source aka winget-pkgs)

The msstore source requires agreements to be accepted. And in your case, passing --accept-source-agreements does accept the source agreements. It can be confirmed in the console output that "Do you agree to the teams?" prompt is not shown and winget moves on to work on the winget source later.

The failure 0x8a15000f : Data required by the source is missing actually is from the winget source. This error code means the winget source's index package cannot be found. Does the machine have access to https://cdn.winget.microsoft.com/cache/source.msix and allow deployment of the index package? Usually you can run winget source update to force update winget sources.

TripleNico commented 1 year ago

Winget has 2 default sources: msstore (the Microsoft Store source) and winget (community source aka winget-pkgs)

The msstore source requires agreements to be accepted. And in your case, passing --accept-source-agreements does accept the source agreements. It can be confirmed in the console output that "Do you agree to the teams?" prompt is not shown and winget moves on to work on the winget source later.

The failure 0x8a15000f : Data required by the source is missing actually is from the winget source. This error code means the winget source's index package cannot be found. Does the machine have access to https://cdn.winget.microsoft.com/cache/source.msix and allow deployment of the index package? Usually you can run winget source update to force update winget sources.

Thanks for your swift reply. I checked if i have acces to the winget source and that's no problem. Other things i could try?

denelon commented 1 year ago

Only REST sources like "msstore" may have "source agreements". Passing "--accept-source-agreements" will eliminate the need for an interactive response. The "msstore" source also has package agreements. Passing "--accept-package-agreements" will eliminate the need for an interactive response.

The WinGet community repository (a.k.a. the "winget" source) is not a REST source does not allow package agreements yet.

If you pass the source "--source msstore" or "--source winget" you will eliminate the need for checking across multiple sources.

The name "query" value you are passing appears to be from the Microsoft Store, I would suggest:

winget upgrade "Adobe Acrobat (64-bit)" --source msstore --silent --accept-source-agreements --accept-package-agreements

I think the error is coming from an issue related to searching the "winget" source which wouldn't be necessary in this explicit case.

TripleNico commented 1 year ago

Hmmm alright, that isn't really helpfull since adobe was just an example. So what would be the right way to install Winget remote and then exept the EULA silently? Or is it only possible as described below. The thing i tried with GPO should also work right?

What i also noticed is when i run this:

winget list --exact --id "Microsoft.VisualStudioCode"

I get this error:

Failed when searching source; results will not be included: winget
No installed package found matching input criteria.

I think this is also related to not being able to trust the source(s)?

denelon commented 1 year ago

WinGet is distributed as a component inside the "App Installer". It's an MSIX package so there are several challenges associated with calling WinGet remotely. We're still working through some of these challenges.

You might want to look at: