Skip to content
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

0x8a15000f : Data required by the source is missing #3068

Open
tomhoad opened this issue Mar 13, 2023 · 27 comments
Open

0x8a15000f : Data required by the source is missing #3068

tomhoad opened this issue Mar 13, 2023 · 27 comments
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation.
Milestone

Comments

@tomhoad
Copy link

tomhoad commented Mar 13, 2023

Brief description of your issue

Receive error message 0x8a15000f : Data required by the source is missing when doing pretty much anything with Winget.

Steps to reproduce

winget upgrade --all --verbose-logs

Expected behavior

winget downloads the package, and the sources are reachable

Actual behavior

C:\Users\xx> winget source list
Name    Argument
-----------------------------------------------------
msstore https://storeedgefd.dsx.mp.microsoft.com/v9.0
winget  https://cdn.winget.microsoft.com/cache

C:\Users\xx> winget search Windows.PowerShell
Failed when searching source; results will not be included: winget
No package found matching input criteria.

C:\Users\xx> winget upgrade --all --verbose-logs
Failed when searching source: winget
An unexpected error occurred while executing the command:
0x8a15000f : Data required by the source is missing

Environment

Windows: Windows.Desktop v10.0.19045.2604
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
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage Issue need to be triaged label Mar 13, 2023
@denelon
Copy link
Contributor

denelon commented Mar 13, 2023

@tomhoad If you run winget list winget which version of the "Windows Package Manager Source (winget)" is installed?

Have you tried running winget source reset --force in administrator mode?

The pre-indexed cache is located at https://cdn.winget.microsoft.com/cache/source.msix.

The client will attempt to download and install the cache based on the default TTL of five minutes (or what is configured via winget settings).

@denelon denelon added Issue-Bug It either shouldn't be doing this or needs an investigation. and removed Needs-Triage Issue need to be triaged labels Mar 13, 2023
@tomhoad
Copy link
Author

tomhoad commented Mar 13, 2023

PS C:\Users\xx> winget list winget
Failed when searching source; results will not be included: winget
No installed package found matching input criteria.
C:\Users\xx> winget -v
v1.4.10173

From an administrator terminal:

C:\Users\xx> winget -v
v1.4.10173
C:\Users\xx>  winget source reset --force
Resetting all sources...Done
C:\Users\xx> winget source list
Name    Argument
-----------------------------------------------------
msstore https://storeedgefd.dsx.mp.microsoft.com/v9.0
winget  https://cdn.winget.microsoft.com/cache

@denelon
Copy link
Contributor

denelon commented Mar 13, 2023

Could you try downloading and manually installing the source.msix package and then running winget list (within 5 minutes of the install)?

I'd really love to figure out what the actual root cause of this is. It's an intermittent problem from "my" perspective as "it works on my machine ™️". I suspect it's either something with some file permissions, or network related issue, but it's been pretty tricky to fully isolate.

@Ithendyr
Copy link

Hi, i'm not sure it's related to this but got the same issue. I'm currently trying to automate the usage of Winget in our environnement but still blocked with this and didn't yet find a workaround.
During my searches i find a wait to replicate this issue every time.

When the Terms of Transaction isn't yet accepted in a case you use the first time Winget, the app ask you about and need an user interaction to accept the terms.
If you run an install command with the parameters --accept-source-agreements and/or --accept-package-agreements without have accepted the terms before, it prompt the terms acceptance message but do not ask the user and the result is the same as you refuse to accept the terms.
I only encounter this issue in an admin powershell prompt and i cannot run the command winget source reset --force as a user because it need admin rights to do.

  • Screen capture of an admin powershell prompt when trying to install an app with parameters --accept-source-agreements --accept-package-agreements after have reset Winget.
    2023-03-17 15_32_05-Olympe - 192 168 150 50 - Connexion Bureau à distance

  • Screen capture of an admin powershell prompt when trying to install an app without parameters --accept-source-agreements --accept-package-agreements after have reset Winget.
    2023-03-17 15_32_47-Olympe - 192 168 150 50 - Connexion Bureau à distance

  • Current version of Winget.
    2023-03-17 15_39_03-Olympe - 192 168 150 50 - Connexion Bureau à distance

I've installed the latest source.msix as indicated above but got the same issue with it. Hope it help.

@denelon denelon added this to the v.Next-Client milestone Jun 5, 2023
@SudoNova
Copy link

SudoNova commented Sep 12, 2023

Hi. I have the same issue:

PS C:\Windows\system32> winget source reset  --force
Resetting all sources...Done
PS C:\Windows\system32> winget install Rustlang.Rust.GNU
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: Yes
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.
PS C:\Windows\system32> winget install Rustlang.Rust.GNU --source winget
Failed when opening source(s); try the 'source reset' command if the problem persists.
An unexpected error occurred while executing the command:
0x8a15000f : Data required by the source is missing
PS C:\Windows\system32> winget --version
v1.5.2201

@inv4lid
Copy link

inv4lid commented Sep 20, 2023

Have, same issue here.
As a hint to reproduce:
Running the commands in administrative shell (as scheduled task when logged in as a "normal" user) I get the errors. When logging in with Athe local adminstrative account I am able to winget upgrade (nothing else) successfully. After relogging in as the "normal" user the task runs fine.
It seems it has something to to with anything in the user context, what is set after a "real" login of the admin...

@ecaha
Copy link

ecaha commented Oct 4, 2023

I have the same issue, if I am building a golden image through packer. I have set of winget commands as a part of install-sw.ps1 script. If it runs unattended as a part of the packer build, it fails with same error. If i finish the build just before the script runs and execute it in real RDP session, it works.

So the context of real login vs. winrm login seems to be the right lead. I do not have the workaround :-(

@gustavohellwig
Copy link

Same error here. It has been working for months, and now it has started to show this error.

@code-ga
Copy link

code-ga commented Oct 15, 2023

i have same error
image

@gustavohellwig
Copy link

It's a bug in the old version. You can fix by updating it. You can use this script below:

function Install-WinGet {
  $tempFolderName = 'WinGetInstall'
  $tempFolder = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath $tempFolderName
  New-Item $tempFolder -ItemType Directory -ErrorAction SilentlyContinue | Out-Null

  $apiLatestUrl = if ($Prerelease) { 'https://api.github.com/repos/microsoft/winget-cli/releases?per_page=1' } else { 'https://api.github.com/repos/microsoft/winget-cli/releases/latest' }
  [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  $WebClient = New-Object System.Net.WebClient

  function Get-LatestUrl	{
		((Invoke-WebRequest $apiLatestUrl -UseBasicParsing | ConvertFrom-Json).assets | Where-Object { $_.name -match '^Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle$' }).browser_download_url
  }

  function Get-LatestHash {
    $shaUrl = ((Invoke-WebRequest $apiLatestUrl -UseBasicParsing | ConvertFrom-Json).assets | Where-Object { $_.name -match '^Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.txt$' }).browser_download_url
    $shaFile = Join-Path -Path $tempFolder -ChildPath 'Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.txt'
    $WebClient.DownloadFile($shaUrl, $shaFile)
    Get-Content $shaFile
  }
  $desktopAppInstaller = @{
    fileName = 'Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle'
    url      = $(Get-LatestUrl)
    hash     = $(Get-LatestHash)
  }
  $vcLibsUwp = @{
    fileName = 'Microsoft.VCLibs.x64.14.00.Desktop.appx'
    url      = 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx'
    hash     = '9BFDE6CFCC530EF073AB4BC9C4817575F63BE1251DD75AAA58CB89299697A569'
  }
  $uiLibsUwp = @{
    fileName = 'Microsoft.UI.Xaml.2.7.zip'
    url      = 'https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.0'
    hash     = '422FD24B231E87A842C4DAEABC6A335112E0D35B86FAC91F5CE7CF327E36A591'
  }
  $dependencies = @($desktopAppInstaller, $vcLibsUwp, $uiLibsUwp)
  Write-Host '--> Checking dependencies'
  foreach ($dependency in $dependencies) {
    $dependency.file = Join-Path -Path $tempFolder -ChildPath $dependency.fileName
    if (-Not ((Test-Path -Path $dependency.file -PathType Leaf) -And $dependency.hash -eq $(Get-FileHash $dependency.file).Hash)) {
      Write-Host @"
    - Downloading:
      $($dependency.url)
"@
      try {
        $WebClient.DownloadFile($dependency.url, $dependency.file)
      }
      catch {
        #Pass the exception as an inner exception
        throw [System.Net.WebException]::new("Error downloading $($dependency.url).", $_.Exception)
      }
      if (-not ($dependency.hash -eq $(Get-FileHash $dependency.file).Hash)) {
        throw [System.Activities.VersionMismatchException]::new('Dependency hash does not match the downloaded file')
      }
    }
  }

  if (-Not (Test-Path (Join-Path -Path $tempFolder -ChildPath \Microsoft.UI.Xaml.2.7\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx)))	{
    Expand-Archive -Path $uiLibsUwp.file -DestinationPath ($tempFolder + '\Microsoft.UI.Xaml.2.7') -Force
  }
  $uiLibsUwp.file = (Join-Path -Path $tempFolder -ChildPath \Microsoft.UI.Xaml.2.7\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx)
  Add-AppxPackage -Path $($desktopAppInstaller.file) -DependencyPath $($vcLibsUwp.file), $($uiLibsUwp.file)
  Remove-Item $tempFolder -recurse -force
}
Write-Host -ForegroundColor Green "--> Updating Winget`n"
Install-Winget

@fgendorf
Copy link

If anyone want install winget to all Users, change
from

Add-AppxPackage -Path $($desktopAppInstaller.file) -DependencyPath $($vcLibsUwp.file), $($uiLibsUwp.file)

to

Add-AppxProvisionedPackage -SkipLicense -online -PackagePath $($desktopAppInstaller.file) -DependencyPackagePath $($vcLibsUwp.file), $($uiLibsUwp.file)

@smithnigelw
Copy link

For me, the fix for 0x8a15000f was to run the following command in PowerShell:

Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.Winget.Source_8wekyb3d8bbwe

@BrianL-STCU
Copy link

BrianL-STCU commented Nov 7, 2023

Similar issue here: winget works fine from my non-elevated account, but then I have to re-authenticate with an elevated account for each machine-scoped install, which sort of defeats the purpose of automating updates.

From the elevated account:

PS C:\Users\brianlalonde# winget upgrade --all
Failed when searching source: winget
An unexpected error occurred while executing the command:
0x8a15000f : Data required by the source is missing
PS C:\Users\brianlalonde# winget search terminal -s winget
Failed when opening source(s); try the 'source reset' command if the problem persists.
An unexpected error occurred while executing the command:
0x8a15000f : Data required by the source is missing
PS C:\Users\brianlalonde# winget source reset --force
Resetting all sources...Done
PS C:\Users\brianlalonde# winget search terminal -s winget
Failed when opening source(s); try the 'source reset' command if the problem persists.
An unexpected error occurred while executing the command:
0x8a15000f : Data required by the source is missing
PS C:\Users\brianlalonde# winget -v
v1.6.2771

@aygupt1822
Copy link

@smithnigelw Your fix worked for me, thanks : )

@MrTechGadget
Copy link

MrTechGadget commented Dec 13, 2023

For me, the fix for 0x8a15000f was to run the following command in PowerShell:

Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.Winget.Source_8wekyb3d8bbwe

Worked for me as well, thank you!!! @smithnigelw

@system-thoughts
Copy link

It's a bug in the old version. You can fix by updating it. You can use this script below:

function Install-WinGet {
  $tempFolderName = 'WinGetInstall'
  $tempFolder = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath $tempFolderName
  New-Item $tempFolder -ItemType Directory -ErrorAction SilentlyContinue | Out-Null

  $apiLatestUrl = if ($Prerelease) { 'https://api.github.com/repos/microsoft/winget-cli/releases?per_page=1' } else { 'https://api.github.com/repos/microsoft/winget-cli/releases/latest' }
  [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  $WebClient = New-Object System.Net.WebClient

  function Get-LatestUrl	{
		((Invoke-WebRequest $apiLatestUrl -UseBasicParsing | ConvertFrom-Json).assets | Where-Object { $_.name -match '^Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle$' }).browser_download_url
  }

  function Get-LatestHash {
    $shaUrl = ((Invoke-WebRequest $apiLatestUrl -UseBasicParsing | ConvertFrom-Json).assets | Where-Object { $_.name -match '^Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.txt$' }).browser_download_url
    $shaFile = Join-Path -Path $tempFolder -ChildPath 'Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.txt'
    $WebClient.DownloadFile($shaUrl, $shaFile)
    Get-Content $shaFile
  }
  $desktopAppInstaller = @{
    fileName = 'Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle'
    url      = $(Get-LatestUrl)
    hash     = $(Get-LatestHash)
  }
  $vcLibsUwp = @{
    fileName = 'Microsoft.VCLibs.x64.14.00.Desktop.appx'
    url      = 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx'
    hash     = '9BFDE6CFCC530EF073AB4BC9C4817575F63BE1251DD75AAA58CB89299697A569'
  }
  $uiLibsUwp = @{
    fileName = 'Microsoft.UI.Xaml.2.7.zip'
    url      = 'https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.0'
    hash     = '422FD24B231E87A842C4DAEABC6A335112E0D35B86FAC91F5CE7CF327E36A591'
  }
  $dependencies = @($desktopAppInstaller, $vcLibsUwp, $uiLibsUwp)
  Write-Host '--> Checking dependencies'
  foreach ($dependency in $dependencies) {
    $dependency.file = Join-Path -Path $tempFolder -ChildPath $dependency.fileName
    if (-Not ((Test-Path -Path $dependency.file -PathType Leaf) -And $dependency.hash -eq $(Get-FileHash $dependency.file).Hash)) {
      Write-Host @"
    - Downloading:
      $($dependency.url)
"@
      try {
        $WebClient.DownloadFile($dependency.url, $dependency.file)
      }
      catch {
        #Pass the exception as an inner exception
        throw [System.Net.WebException]::new("Error downloading $($dependency.url).", $_.Exception)
      }
      if (-not ($dependency.hash -eq $(Get-FileHash $dependency.file).Hash)) {
        throw [System.Activities.VersionMismatchException]::new('Dependency hash does not match the downloaded file')
      }
    }
  }

  if (-Not (Test-Path (Join-Path -Path $tempFolder -ChildPath \Microsoft.UI.Xaml.2.7\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx)))	{
    Expand-Archive -Path $uiLibsUwp.file -DestinationPath ($tempFolder + '\Microsoft.UI.Xaml.2.7') -Force
  }
  $uiLibsUwp.file = (Join-Path -Path $tempFolder -ChildPath \Microsoft.UI.Xaml.2.7\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx)
  Add-AppxPackage -Path $($desktopAppInstaller.file) -DependencyPath $($vcLibsUwp.file), $($uiLibsUwp.file)
  Remove-Item $tempFolder -recurse -force
}
Write-Host -ForegroundColor Green "--> Updating Winget`n"
Install-Winget

This helps me a lot, the problem solved!!

@code-ga
Copy link

code-ga commented Dec 19, 2023

For me, the fix for 0x8a15000f was to run the following command in PowerShell:

Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.Winget.Source_8wekyb3d8bbwe

I have an error when running that command
image

@saurabhgupta1233
Copy link

It's a bug in the old version. You can fix by updating it. You can use this script below:

function Install-WinGet {
  $tempFolderName = 'WinGetInstall'
  $tempFolder = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath $tempFolderName
  New-Item $tempFolder -ItemType Directory -ErrorAction SilentlyContinue | Out-Null

  $apiLatestUrl = if ($Prerelease) { 'https://api.github.com/repos/microsoft/winget-cli/releases?per_page=1' } else { 'https://api.github.com/repos/microsoft/winget-cli/releases/latest' }
  [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  $WebClient = New-Object System.Net.WebClient

  function Get-LatestUrl	{
		((Invoke-WebRequest $apiLatestUrl -UseBasicParsing | ConvertFrom-Json).assets | Where-Object { $_.name -match '^Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle$' }).browser_download_url
  }

  function Get-LatestHash {
    $shaUrl = ((Invoke-WebRequest $apiLatestUrl -UseBasicParsing | ConvertFrom-Json).assets | Where-Object { $_.name -match '^Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.txt$' }).browser_download_url
    $shaFile = Join-Path -Path $tempFolder -ChildPath 'Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.txt'
    $WebClient.DownloadFile($shaUrl, $shaFile)
    Get-Content $shaFile
  }
  $desktopAppInstaller = @{
    fileName = 'Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle'
    url      = $(Get-LatestUrl)
    hash     = $(Get-LatestHash)
  }
  $vcLibsUwp = @{
    fileName = 'Microsoft.VCLibs.x64.14.00.Desktop.appx'
    url      = 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx'
    hash     = '9BFDE6CFCC530EF073AB4BC9C4817575F63BE1251DD75AAA58CB89299697A569'
  }
  $uiLibsUwp = @{
    fileName = 'Microsoft.UI.Xaml.2.7.zip'
    url      = 'https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.0'
    hash     = '422FD24B231E87A842C4DAEABC6A335112E0D35B86FAC91F5CE7CF327E36A591'
  }
  $dependencies = @($desktopAppInstaller, $vcLibsUwp, $uiLibsUwp)
  Write-Host '--> Checking dependencies'
  foreach ($dependency in $dependencies) {
    $dependency.file = Join-Path -Path $tempFolder -ChildPath $dependency.fileName
    if (-Not ((Test-Path -Path $dependency.file -PathType Leaf) -And $dependency.hash -eq $(Get-FileHash $dependency.file).Hash)) {
      Write-Host @"
    - Downloading:
      $($dependency.url)
"@
      try {
        $WebClient.DownloadFile($dependency.url, $dependency.file)
      }
      catch {
        #Pass the exception as an inner exception
        throw [System.Net.WebException]::new("Error downloading $($dependency.url).", $_.Exception)
      }
      if (-not ($dependency.hash -eq $(Get-FileHash $dependency.file).Hash)) {
        throw [System.Activities.VersionMismatchException]::new('Dependency hash does not match the downloaded file')
      }
    }
  }

  if (-Not (Test-Path (Join-Path -Path $tempFolder -ChildPath \Microsoft.UI.Xaml.2.7\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx)))	{
    Expand-Archive -Path $uiLibsUwp.file -DestinationPath ($tempFolder + '\Microsoft.UI.Xaml.2.7') -Force
  }
  $uiLibsUwp.file = (Join-Path -Path $tempFolder -ChildPath \Microsoft.UI.Xaml.2.7\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx)
  Add-AppxPackage -Path $($desktopAppInstaller.file) -DependencyPath $($vcLibsUwp.file), $($uiLibsUwp.file)
  Remove-Item $tempFolder -recurse -force
}
Write-Host -ForegroundColor Green "--> Updating Winget`n"
Install-Winget

Got the same error as @code-ga. But after running the above script, did a source force reset
winget source reset --force and it started working. Kudos to the answer.

@klangborste
Copy link

It's a bug in the old version. You can fix by updating it. You can use this script below:

function Install-WinGet {
  $tempFolderName = 'WinGetInstall'
  $tempFolder = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath $tempFolderName
  New-Item $tempFolder -ItemType Directory -ErrorAction SilentlyContinue | Out-Null

  $apiLatestUrl = if ($Prerelease) { 'https://api.github.com/repos/microsoft/winget-cli/releases?per_page=1' } else { 'https://api.github.com/repos/microsoft/winget-cli/releases/latest' }
  [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  $WebClient = New-Object System.Net.WebClient

  function Get-LatestUrl	{
		((Invoke-WebRequest $apiLatestUrl -UseBasicParsing | ConvertFrom-Json).assets | Where-Object { $_.name -match '^Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle$' }).browser_download_url
  }

  function Get-LatestHash {
    $shaUrl = ((Invoke-WebRequest $apiLatestUrl -UseBasicParsing | ConvertFrom-Json).assets | Where-Object { $_.name -match '^Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.txt$' }).browser_download_url
    $shaFile = Join-Path -Path $tempFolder -ChildPath 'Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.txt'
    $WebClient.DownloadFile($shaUrl, $shaFile)
    Get-Content $shaFile
  }
  $desktopAppInstaller = @{
    fileName = 'Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle'
    url      = $(Get-LatestUrl)
    hash     = $(Get-LatestHash)
  }
  $vcLibsUwp = @{
    fileName = 'Microsoft.VCLibs.x64.14.00.Desktop.appx'
    url      = 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx'
    hash     = '9BFDE6CFCC530EF073AB4BC9C4817575F63BE1251DD75AAA58CB89299697A569'
  }
  $uiLibsUwp = @{
    fileName = 'Microsoft.UI.Xaml.2.7.zip'
    url      = 'https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.0'
    hash     = '422FD24B231E87A842C4DAEABC6A335112E0D35B86FAC91F5CE7CF327E36A591'
  }
  $dependencies = @($desktopAppInstaller, $vcLibsUwp, $uiLibsUwp)
  Write-Host '--> Checking dependencies'
  foreach ($dependency in $dependencies) {
    $dependency.file = Join-Path -Path $tempFolder -ChildPath $dependency.fileName
    if (-Not ((Test-Path -Path $dependency.file -PathType Leaf) -And $dependency.hash -eq $(Get-FileHash $dependency.file).Hash)) {
      Write-Host @"
    - Downloading:
      $($dependency.url)
"@
      try {
        $WebClient.DownloadFile($dependency.url, $dependency.file)
      }
      catch {
        #Pass the exception as an inner exception
        throw [System.Net.WebException]::new("Error downloading $($dependency.url).", $_.Exception)
      }
      if (-not ($dependency.hash -eq $(Get-FileHash $dependency.file).Hash)) {
        throw [System.Activities.VersionMismatchException]::new('Dependency hash does not match the downloaded file')
      }
    }
  }

  if (-Not (Test-Path (Join-Path -Path $tempFolder -ChildPath \Microsoft.UI.Xaml.2.7\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx)))	{
    Expand-Archive -Path $uiLibsUwp.file -DestinationPath ($tempFolder + '\Microsoft.UI.Xaml.2.7') -Force
  }
  $uiLibsUwp.file = (Join-Path -Path $tempFolder -ChildPath \Microsoft.UI.Xaml.2.7\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx)
  Add-AppxPackage -Path $($desktopAppInstaller.file) -DependencyPath $($vcLibsUwp.file), $($uiLibsUwp.file)
  Remove-Item $tempFolder -recurse -force
}
Write-Host -ForegroundColor Green "--> Updating Winget`n"
Install-Winget

very helpful answer, searched a while for a solution. thanks a lot.

@MichaelNeero
Copy link

Tried all of the above fixes without any luck. (Fresh Win11 Pro install)

Only thing that worked for me was the following:
Add-AppPackage -path "https://cdn.winget.microsoft.com/cache/source.msix."

Afterwards the error was resolved and I was able to use winget.

@BrianL-STCU
Copy link

I ran @gustavohellwig 's script, but that didn't seem to fix it, while @MichaelNeero 's command did! If I can confirm that adding the source package alone works for someone else, I'll add an update. Otherwise, it may have been running both that worked.

@florianriededeka
Copy link

florianriededeka commented Mar 11, 2024

Install winget in a packer build via winrm this way:

`# Download
Write-Host "Downloading WinGet..."
Invoke-WebRequest -Uri https://aka.ms/getwinget -OutFile Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
Write-Host "Downloading VCLibs..."
Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx
Write-Host "Downloading UI.Xaml..."
Invoke-WebRequest -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx -OutFile Microsoft.UI.Xaml.2.8.x64.appx
Installation
Write-Host "Installing VCLibs..."
Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx
Write-Host "Installing UI.Xaml..."
Add-AppxPackage Microsoft.UI.Xaml.2.8.x64.appx
Write-Host "Installing WinGet..."
Add-AppxPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle

Stop-Transcript
`

After that i install applications in the packer build and get the following error:

image

@garreh89
Copy link

garreh89 commented Apr 1, 2024

@MichaelNeero Thanks, this worked a treat!

@taskscheduler
Copy link

It's a bug in the old version. You can fix by updating it. You can use this script below:

function Install-WinGet {
  $tempFolderName = 'WinGetInstall'
  $tempFolder = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath $tempFolderName
  New-Item $tempFolder -ItemType Directory -ErrorAction SilentlyContinue | Out-Null

  $apiLatestUrl = if ($Prerelease) { 'https://api.github.com/repos/microsoft/winget-cli/releases?per_page=1' } else { 'https://api.github.com/repos/microsoft/winget-cli/releases/latest' }
  [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  $WebClient = New-Object System.Net.WebClient

  function Get-LatestUrl	{
		((Invoke-WebRequest $apiLatestUrl -UseBasicParsing | ConvertFrom-Json).assets | Where-Object { $_.name -match '^Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle$' }).browser_download_url
  }

  function Get-LatestHash {
    $shaUrl = ((Invoke-WebRequest $apiLatestUrl -UseBasicParsing | ConvertFrom-Json).assets | Where-Object { $_.name -match '^Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.txt$' }).browser_download_url
    $shaFile = Join-Path -Path $tempFolder -ChildPath 'Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.txt'
    $WebClient.DownloadFile($shaUrl, $shaFile)
    Get-Content $shaFile
  }
  $desktopAppInstaller = @{
    fileName = 'Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle'
    url      = $(Get-LatestUrl)
    hash     = $(Get-LatestHash)
  }
  $vcLibsUwp = @{
    fileName = 'Microsoft.VCLibs.x64.14.00.Desktop.appx'
    url      = 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx'
    hash     = '9BFDE6CFCC530EF073AB4BC9C4817575F63BE1251DD75AAA58CB89299697A569'
  }
  $uiLibsUwp = @{
    fileName = 'Microsoft.UI.Xaml.2.7.zip'
    url      = 'https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.0'
    hash     = '422FD24B231E87A842C4DAEABC6A335112E0D35B86FAC91F5CE7CF327E36A591'
  }
  $dependencies = @($desktopAppInstaller, $vcLibsUwp, $uiLibsUwp)
  Write-Host '--> Checking dependencies'
  foreach ($dependency in $dependencies) {
    $dependency.file = Join-Path -Path $tempFolder -ChildPath $dependency.fileName
    if (-Not ((Test-Path -Path $dependency.file -PathType Leaf) -And $dependency.hash -eq $(Get-FileHash $dependency.file).Hash)) {
      Write-Host @"
    - Downloading:
      $($dependency.url)
"@
      try {
        $WebClient.DownloadFile($dependency.url, $dependency.file)
      }
      catch {
        #Pass the exception as an inner exception
        throw [System.Net.WebException]::new("Error downloading $($dependency.url).", $_.Exception)
      }
      if (-not ($dependency.hash -eq $(Get-FileHash $dependency.file).Hash)) {
        throw [System.Activities.VersionMismatchException]::new('Dependency hash does not match the downloaded file')
      }
    }
  }

  if (-Not (Test-Path (Join-Path -Path $tempFolder -ChildPath \Microsoft.UI.Xaml.2.7\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx)))	{
    Expand-Archive -Path $uiLibsUwp.file -DestinationPath ($tempFolder + '\Microsoft.UI.Xaml.2.7') -Force
  }
  $uiLibsUwp.file = (Join-Path -Path $tempFolder -ChildPath \Microsoft.UI.Xaml.2.7\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx)
  Add-AppxPackage -Path $($desktopAppInstaller.file) -DependencyPath $($vcLibsUwp.file), $($uiLibsUwp.file)
  Remove-Item $tempFolder -recurse -force
}
Write-Host -ForegroundColor Green "--> Updating Winget`n"
Install-Winget

Thanks for this, it fixed the issue quickly. Appreciate it!

albertdev added a commit to albertdev/dotfiles that referenced this issue Apr 3, 2024
A fresh Windows 11 Pro install ran into
microsoft/winget-cli#3068
@Tims777
Copy link

Tims777 commented May 3, 2024

Had the same issue on a fresh install of Windows 11. The installation from CDN fixed it for me.

Only thing that worked for me was the following: Add-AppPackage -path "https://cdn.winget.microsoft.com/cache/source.msix."

Could it be that the issue is linked to doing an offline installation? (I did connect my WiFi only after the installation, so that I could set up a local account.)

@haydenzeller
Copy link

I second this. I have only had this issue when doing an offline install of windows 11. Adding the CDN fixed it 👍

Had the same issue on a fresh install of Windows 11. The installation from CDN fixed it for me.

Only thing that worked for me was the following: Add-AppPackage -path "https://cdn.winget.microsoft.com/cache/source.msix."

Could it be that the issue is linked to doing an offline installation? (I did connect my WiFi only after the installation, so that I could set up a local account.)

@bartvdbraak
Copy link

Tried all of the above fixes without any luck. (Fresh Win11 Pro install)

Only thing that worked for me was the following: Add-AppPackage -path "https://cdn.winget.microsoft.com/cache/source.msix."

Afterwards the error was resolved and I was able to use winget.

This worked perfectly! (Also did an offline installation)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation.
Projects
None yet
Development

No branches or pull requests