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

"System.NotImplementedException" in Microsoft.Windows.Management.Deployment.ResetPackageAsync version 1.6.241114003 #5031

Open
tonymet opened this issue Jan 14, 2025 · 6 comments
Labels
area-Deployment Issues related to packaging, installation, runtime (e.g., SelfContained, Unpackaged)

Comments

@tonymet
Copy link

tonymet commented Jan 14, 2025

Describe the bug

Microsoft.Windows.Management.Deployment.ResetPackageAsync() (documentation) raises System.NotImplementedException . Other methods are working in the same namespace , including IsPackageReady . Documentations says the methods are supported since WinSDK 1.5 .

Example Code:
https://gist.github.com/tonymet/35f8c24e8f27e010c1cdea621abf85dd#file-mainwindow-xaml-cs

Steps to reproduce the bug

  1. create a method with this call
var resultsList = pm.FindPackagesForUserWithPackageTypes(string.Empty, PackageTypes.Main);
foreach (var item in resultsList)
{
    Debug.WriteLine(item.DisplayName);
    var result1 = pdm.IsPackageReady(item.Id.FullName);  // returns true
    var result2 = await pdm.ResetPackageAsync(item.Id.FullName);   // throws System.NotImplementedException
}

Expected behavior

msix package should be reset, similar to Powershell cmdlet Reset-AppxPackage

Screenshots

Example .cs & exception trace

System.NotImplementedException
  HResult=0x80004001
  Message=Not implemented

Not implemented

  Source=WinRT.Runtime
  StackTrace:
   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|38_0(Int32 hr)
   at ABI.Microsoft.Windows.Management.Deployment.IPackageDeploymentManagerMethods.ResetPackageAsync(IObjectReference _obj, String package)
   at Microsoft.Windows.Management.Deployment.PackageDeploymentManager.ResetPackageAsync(String package)
   at PackagesCleanup.MainWindow.<resetItem_Click>d__9.MoveNext() in C:\Users\tonymet\source\repos\PackagesCleanup\PackagesCleanup\MainWindow.xaml.cs:line 62

NuGet package version

Windows App SDK 1.6.3: 1.6.241114003

Packaging type

Packaged (MSIX)

Windows version

Insider Build (Version 10.0.22635 Build 22635)

IDE

Visual Studio 2022

Additional context

OS Name Microsoft Windows 11 Pro
Version 10.0.22635 Build 22635

Properties

 <TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
 <TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
  <SupportedOSPlatformVersion>10.0.26100.0</SupportedOSPlatformVersion>
 <ItemGroup>
   <PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
   <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.241114003" />
 </ItemGroup>
@tonymet tonymet changed the title "Not Yet Implemented" in Microsoft.Windows.Management.Deployment.ResetPackageAsync version 1.6.241114003 "System.NotImplementedException" in Microsoft.Windows.Management.Deployment.ResetPackageAsync version 1.6.241114003 Jan 14, 2025
@tonymet
Copy link
Author

tonymet commented Jan 14, 2025

related: #4817

@tonymet
Copy link
Author

tonymet commented Jan 14, 2025

@whiskhub
Copy link

whiskhub commented Jan 16, 2025

I think you're first supposed to call PackageDeploymentManager.IsPackageDeploymentFeatureSupported(PackageDeploymentFeature.ResetPackage) and check whether the feature is supported (which is always returning false). So I guess it's expected.

The documentation is sadly still quite terrible, there is no mention of this: https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.windows.management.deployment.packagedeploymentmanager.ispackagedeploymentfeaturesupported?view=windows-app-sdk-1.6

@whiskhub
Copy link

Although I do wonder, why can PowerShell reset a MSIX package but not the WASDK?

I ilspied into the Reset-AppxPackage PowerShell code, and it seems to be calling some undocumented function. Seems to be just as undocumented as the MsixResetPackageAsync function initially mentioned in the WASDK code.

[DllImport("AppXDeploymentClient.dll")]
private static extern int AppxResetPackage([MarshalAs(UnmanagedType.LPWStr)] string moniker);

@tonymet
Copy link
Author

tonymet commented Jan 17, 2025

PackageDeploymentManager.IsPackageDeploymentFeatureSupported(PackageDeploymentFeature.ResetPackage) a

thank you and you are right that the call returns false. This bug may be best addressed by updating the documentation. why have the API if it's hardcoded false?

@tonymet
Copy link
Author

tonymet commented Jan 17, 2025

thank you for the dllspy tip . I'll see if I can reverse-engineer that call.

@RDMacLachlan RDMacLachlan added area-Deployment Issues related to packaging, installation, runtime (e.g., SelfContained, Unpackaged) and removed needs-triage labels Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Deployment Issues related to packaging, installation, runtime (e.g., SelfContained, Unpackaged)
Projects
None yet
Development

No branches or pull requests

3 participants