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
22.54k stars 1.39k forks source link

Unable to Add-AppxProvisionedPackage as System since 1.7.11132 #4431

Open tonnesen-ncqa opened 2 months ago

tonnesen-ncqa commented 2 months ago

Brief description of your issue

Until now, I have been using a W32 app in Intune to install Winget as a nt/system. As of release 1.7.11132, this is no longer working. I also tried using the latest pre-release and saw the same issue. I see this same issue when running as a local administrator as well.

Steps to reproduce

  1. Download latest msixbundle: https://github.com/microsoft/winget-cli/releases/tag/v1.7.11132
  2. As nt/system or local administrator run Add-AppxProvisionedPackage -Online -PackagePath "$InstallerFolder\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -SkipLicense

Expected behavior

AppxPackage provisions without error. I attached appx and dism logs below. I am seeing an error regarding: Opening the package from location Microsoft.UI.Xaml.2.8_8.2310.30001.0_x64__8wekyb3d8bbwe failed.

Actual behavior

Get the following error: `Exception : Type : System.Runtime.InteropServices.COMException ErrorCode : -2147024893 TargetSite : Name : ThrowTerminatingError DeclaringType : [System.Management.Automation.MshCommandRuntime] MemberType : Method Module : System.Management.Automation.dll Message : Unspecified error

Source     : System.Management.Automation
HResult    : -2147024893
StackTrace :

at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord) CategoryInfo : NotSpecified: (:) [Add-AppxProvisionedPackage], COMException FullyQualifiedErrorId : Microsoft.Dism.Commands.AddAppxProvisionedPackageCommand InvocationInfo : MyCommand : Add-AppxProvisionedPackage ScriptLineNumber : 111 OffsetInLine : 4 HistoryId : 35 ScriptName : C:\git\Autopilot\w32Apps\microsoft.desktopappinstaller\script.ps1 Line : Add-AppxProvisionedPackage -Online -PackagePath "$InstallerFolder\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -SkipLicense`

dism.log appxlogs.txt

Environment

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

Windows: Windows.Desktop v10.0.19045.4355
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.22.10861.0

Winget Directories                 
-----------------------------------------------------------------------------------------------------------------------
Logs                               %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\Diag…
User Settings                      %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\sett…
Portable Links Directory (User)    %LOCALAPPDATA%\Microsoft\WinGet\Links
Portable Links Directory (Machine) C:\Program Files\WinGet\Links
Portable Package Root (User)       %LOCALAPPDATA%\Microsoft\WinGet\Packages
Portable Package Root              C:\Program Files\WinGet\Packages
Portable Package Root (x86)        C:\Program Files (x86)\WinGet\Packages
Installer Downloads                %USERPROFILE%\Downloads

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

Admin Setting                             State
--------------------------------------------------
LocalManifestFiles                        Disabled
BypassCertificatePinningForMicrosoftStore Disabled
InstallerHashOverride                     Disabled
LocalArchiveMalwareScanOverride           Disabled
PckgrTom commented 2 months ago

Hi, as a workaround could you manually download and install Xaml?

tonnesen-ncqa commented 2 months ago

Hi, as a workaround could you manually download and install Xaml?

I should have included that I tried to manually install Xaml.

**********************
PowerShell transcript start
Start time: 20240501083746
(Microsoft Windows NT 10.0.19045.0)
Host Application: C:\Program Files\PowerShell\7\pwsh.dll -mta
Process ID: 25608
PSVersion: 7.4.2
PSEdition: Core
GitCommitId: 7.4.2
OS: Microsoft Windows 10.0.19045
Platform: Win32NT
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1, 6.0, 7.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
WSManStackVersion: 3.0
**********************
Transcript started, output file is error.log
PS C:\temp\test> whoami
nt authority\system
PS C:\temp\test> get-AppxProvisionedPackage -online | Where-Object {$_.displayname -match "xaml" }

DisplayName  : Microsoft.UI.Xaml.2.8
Version      : 8.2310.30001.0
Architecture : x64
ResourceId   : 
PackageName  : Microsoft.UI.Xaml.2.8_8.2310.30001.0_x64__8wekyb3d8bbwe
Regions      : 

PS C:\temp\test> ls

    Directory: C:\temp\test

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---            5/1/2024  8:37 AM            690 error.log
-a---            5/1/2024  8:27 AM      259315296 Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle

PS C:\temp\test> Add-AppxProvisionedPackage -Online -PackagePath ".\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -SkipLicense
>> TerminatingError(Add-AppxProvisionedPackage): "Unspecified error
"
Add-AppxProvisionedPackage: Unspecified error
Add-AppxProvisionedPackage: Unspecified error

PS C:\temp\test> Get-Error -Last 1

Exception             : 
    Type       : System.Runtime.InteropServices.COMException
    ErrorCode  : -2147024893
    TargetSite : 
        Name          : ThrowTerminatingError
        DeclaringType : [System.Management.Automation.MshCommandRuntime]
        MemberType    : Method
        Module        : System.Management.Automation.dll
    Message    : Unspecified error

    Source     : System.Management.Automation
    HResult    : -2147024893
    StackTrace : 
   at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
CategoryInfo          : NotSpecified: (:) [Add-AppxProvisionedPackage], COMException
FullyQualifiedErrorId : Microsoft.Dism.Commands.AddAppxProvisionedPackageCommand
InvocationInfo        : 
    MyCommand        : Add-AppxProvisionedPackage
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 26
    Line             : Add-AppxProvisionedPackage -Online -PackagePath ".\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -SkipLicense
    Statement        : Add-AppxProvisionedPackage -Online -PackagePath ".\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -SkipLicense
    PositionMessage  : At line:1 char:1
                       + Add-AppxProvisionedPackage -Online -PackagePath ".\Microsoft.DesktopA …
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Add-AppxProvisionedPackage
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

PS C:\temp\test> stop-Transcript
**********************
PowerShell transcript end
End time: 20240501083829
**********************
TrTai commented 2 months ago

Hi, as a workaround could you manually download and install Xaml?

I encountered this issue as well, thankfully my case was a single device and after receiving the same error as a script and running the cmdlet manually, I was able to get this to work around using the nuget package as a zip and installing as an appx package contained inside the zip manually. https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.8.6 for the file used.