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

[Bug]: Windows Sandbox incompatibility #384

Closed
gabriel-vanca opened this issue Aug 24, 2023 · 8 comments
Closed

[Bug]: Windows Sandbox incompatibility #384

gabriel-vanca opened this issue Aug 24, 2023 · 8 comments
Labels
bug Something isn't working stale

Comments

@gabriel-vanca
Copy link

The problem

The install script fails when trying to run in on the Windows 11 Sandbox for two reasons:

  1. The winget install check fails because Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq "Microsoft.DesktopAppInstaller" } returns an empty string. Get-AppPackage -name "Microsoft.DesktopAppInstaller" is the safer option to use.
  2. The winget installation fails because Add-AppxProvisionedPackage -Online -PackagePath "$PSScriptRoot\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -SkipLicense | Out-Null fails. The safer version to use is Add-AppxPackage "$PSScriptRoot\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"

⚠️ Note: These errors are similar to the ones I mentioned in #379 , albeit in that case they were only occurring in PowerShell Core. In Windows Sandbox, they also occur in PowerShell Desktop.

What version of WAU has the issue?

latest

What version of Windows are you using (ex. Windows 11 22H2)?

Windows 11 Sandbox - latest version

What version of winget are you using?

latest

Log information

No response

Additional information

No response

@Romanitho
Copy link
Owner

I don't have any issue in my WSB on windows 11

@KnifMelti
Copy link
Contributor

I can see it on Win 10, but if we include (as in Winget-Install-GUI) it is resolved:

        #Check if Microsoft UI Xaml 2.7.0 is installed
        if (!(Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq "Microsoft.UI.Xaml.2.7" })) {
            try {
                #Install Microsoft UI Xaml 2.7.0
                Write-host "Downloading Microsoft UI Xaml 2.7.0..."
                $UiXamlUrl = "https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.0"
                $UiXamlZip = "$WingetUpdatePath\Microsoft.UI.XAML.2.7.zip"
                Invoke-RestMethod -Uri $UiXamlUrl -OutFile $UiXamlZip
                Expand-Archive -Path $UiXamlZip -DestinationPath "$WingetUpdatePath\extracted" -Force
                Add-AppxProvisionedPackage -Online -PackagePath "$WingetUpdatePath\extracted\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.7.appx" -SkipLicense | Out-Null
                Remove-Item -Path $UiXamlZip -Force -ErrorAction Ignore
                Remove-Item -Path "$WingetUpdatePath\extracted" -Force -Recurse -ErrorAction Ignore
                Write-host "Microsoft UI Xaml 2.7.0 installed successfully" -ForegroundColor Green
            }
            catch {
                Write-host "Microsoft UI Xaml 2.7.0 installation failed." -ForegroundColor Red
            }
        }

        #Check if Microsoft VCLibs x64 14.00 is installed
        if (!(Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq "Microsoft.VCLibs.140.00.UWPDesktop" })) {
            try {
                #Install
                Write-host "Downloading Microsoft VCLibs x64 14.00..."
                $VCLibsUrl = "https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx"
                $VCLibsFile = "$WingetUpdatePath\Microsoft.VCLibs.x64.14.00.Desktop.appx"
                Invoke-RestMethod -Uri $VCLibsUrl -OutFile $VCLibsFile
                Add-AppxProvisionedPackage -Online -PackagePath "$WingetUpdatePath\Microsoft.VCLibs.x64.14.00.Desktop.appx" -SkipLicense | Out-Null
                Remove-Item -Path $VCLibsFile -Force -ErrorAction Ignore
                Write-host "Microsoft VCLibs x64 14.00 installed successfully" -ForegroundColor Green
            }
            catch {
                Write-host "Microsoft VCLibs x64 14.00 installation failed." -ForegroundColor Red
            }
        }

Maybe also (regarding Core):

# import Appx module if the powershell version is 7/core
if ( $psversionTable.PSEdition -eq "core" ) {
    import-Module -name Appx -UseWIndowsPowershell -WarningAction:SilentlyContinue
}

@Romanitho
Copy link
Owner

but yes, Get-AppPackage could be a better option

@Romanitho
Copy link
Owner

but for the Add-AppxPackage, it might depend if it is installed from an admin user or system account (like SCCM or Intune does), I guess

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2023

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Oct 9, 2023
@github-actions
Copy link
Contributor

This issue was closed because it has been inactive for 14 days since being marked as stale.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 23, 2023
@gabriel-vanca
Copy link
Author

gabriel-vanca commented Jan 24, 2024

@KnifMelti
Just to note version 2.8.5 is the latest Microsoft.UI.Xaml version

https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.5/Microsoft.UI.Xaml.2.8.x64.appx

Here's what I use to check for in my scripts:

[String]$UIXAML_VersionToLookFor = "8.2306.22001.0"
$UIXAML_List = Get-AppxPackage Microsoft.UI.Xaml.2.8 | Where-Object version -ge $UIXAML_VersionToLookFor
if([string]::IsNullorEmpty($UIXAML_List)) {
    Write-Host "Microsoft.UI.Xaml version missing" -ForegroundColor DarkMagenta
    Write-Host "Initialising install of Microsoft.UI.Xaml" -ForegroundColor DarkYellow

    $WebClient = New-Object System.Net.WebClient
    # https://github.com/microsoft/microsoft-ui-xaml/releases?q=xaml&expanded=true
    $fileURL = "https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.5/Microsoft.UI.Xaml.2.8.x64.appx"
    $fileDownloadLocalPath = "$env:Temp\Microsoft.UI.Xaml.2.8.x64.appx"
    $WebClient.DownloadFile($fileURL, $fileDownloadLocalPath)

    # Installing the component
    Add-AppxPackage $fileDownloadLocalPath 
    # Removing installation file
    Remove-Item $fileDownloadLocalPath 

    $UIXAML_List = Get-AppxPackage Microsoft.UI.Xaml.2.8 | Where-Object version -ge $UIXAML_VersionToLookFor
    if([string]::IsNullorEmpty($UIXAML_List)) {
        Write-Error "Microsoft UI Xaml installation failed."
    } else {
        Write-Host "Microsoft UI Xaml installed successfully" -ForegroundColor DarkGreen
    }
} 

@gabriel-vanca
Copy link
Author

I've checked and removing version 2.7 breaks things so it definitely looks like both 2.7 and 2.8 needs to be installed.

See also #554

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

3 participants