MicrosoftDocs / windows-dev-docs

Conceptual and overview content for developing Windows apps
Creative Commons Attribution 4.0 International
688 stars 1.2k forks source link

Instructions for Install winget on Windows Sandbox do not work on Windows 10 21H2 #4236

Closed hollowdrutt closed 7 months ago

hollowdrutt commented 1 year ago

The instructions under Install winget on Windows Sandbox do not work on Windows 10 21H2. If you try to run the commands:

$ProgressPreference='Silent'
Invoke-WebRequest -Uri https://github.com/microsoft/winget-cli/releases/download/v1.3.2691/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle -OutFile .\MicrosoftDesktopAppInstaller_8wekyb3d8bbwe.msixbundle
Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx
Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx
Add-AppxPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle

You get an error like

Add-AppxPackage : Cannot find path
'C:\Users\WDAGUtilityAccount\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle' because it does not exist.
At line:1 char:1
+ Add-AppxPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundl ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\WDAGUt...bbwe.msixbundle:String) [Add-AppxPackage], ItemNotFou
   ndException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageCommand

If you correct the OutFile in the first line and change .\MicrosoftDesktopAppInstaller_8wekyb3d8bbwe.msixbundle to .\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle and run the commands

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

You get an error like:

Add-AppxPackage : Deployment failed with HRESULT: 0x80073CF3, Package failed updates, dependency or conflict
validation.
Windows cannot install package Microsoft.DesktopAppInstaller_1.18.2691.0_x64__8wekyb3d8bbwe because this package
depends on a framework that could not be found. Provide the framework "Microsoft.UI.Xaml.2.7" published by
"CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US", with neutral or x64 processor
architecture and minimum version 7.2109.13004.0, along with this package to install. The frameworks with name
"Microsoft.UI.Xaml.2.7" currently installed are: {}
NOTE: For additional information, look for [ActivityId] 4e02d82a-26e9-0000-bfce-064ee926d901 in the Event Log or use
the command line Get-AppPackageLog -ActivityID 4e02d82a-26e9-0000-bfce-064ee926d901
At line:1 char:1
+ Add-AppxPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundl ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (C:\Users\WDAGUt...bbwe.msixbundle:String) [Add-AppxPackage], IOException
    + FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageCommand

If you follow the suggestion in this comment https://github.com/microsoft/winget-cli/issues/1861#issuecomment-1352784247 it works

Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.3 -OutFile .\microsoft.ui.xaml.2.7.3.zip
Expand-Archive .\microsoft.ui.xaml.2.7.3.zip
Add-AppxPackage .\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 .\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
Add-AppxPackage .\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle

Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

glawrence commented 1 year ago

I have raised https://github.com/MicrosoftDocs/windows-dev-docs/issues/4315 which I realise duplicates this one, but I also created PR https://github.com/MicrosoftDocs/windows-dev-docs/pull/4264 which fixes this

mattwojo commented 7 months ago

This issue is resolved and the winget install script for Windows sandbox was recently updated in https://github.com/MicrosoftDocs/windows-dev-docs/commit/cac9dab23803c52be58476538dc44ea9d6cda031. Thanks for filing!