C#C
C#3y ago
swim

❔ Registering an extracted appx package

    public static void RegisterMinecraftAppxPackage(string appxPackagePath) {
      try {
        // Register if it is already extracted
        if (Directory.Exists(appxPackagePath)) {
          // Remove the current install
          DeregisterMinecraftPackage();
          // Invoke PowerShell to register the appx package
          var powerShellCommand = $"Add-AppxPackage -Path '{Path.Combine(appxPackagePath, "AppxManifest.xml")}' -DisableDevelopmentMode -ForceUpdateFromAnyVersion -Register";
          using (var process = new Process {
            // set the values needed
            StartInfo = new ProcessStartInfo {
              FileName = "powershell.exe",
              Arguments = powerShellCommand,
              RedirectStandardOutput = true, // we want to be able to read the response message
              UseShellExecute = false, // dotnet core can handle it for us
              CreateNoWindow = true, // execute headlessley
            }
          }) {
            process.Start();
            string output = process.StandardOutput.ReadToEnd();
            process.WaitForExit();
            Debug.WriteLine(output);
          }
        } else if (Path.GetExtension(appxPackagePath).ToLower().Equals(".appx")) { // Extract then register
          string directoryName = Path.GetFileNameWithoutExtension(appxPackagePath);
          string extractPath = Path.Combine(Path.GetDirectoryName(appxPackagePath), directoryName);
          Directory.CreateDirectory(extractPath);
          ZipFile.ExtractToDirectory(appxPackagePath, extractPath);
          RegisterMinecraftAppxPackage(extractPath); // Recursively register the package
        }
      } catch (Exception e) {
        Debug.WriteLine(e.StackTrace);
      }
    }

This code returns this error:
Add-AppxPackage : Deployment failed with HRESULT: 0x80073CF9, Install failed. Please contact your software vendor. 
(Exception from HRESULT: 0x80073CF9)
Rejecting a request to register from AppxManifest.xml because the manifest is not in the package root.
NOTE: For additional information, look for [ActivityId] f38787bd-5ed2-0005-d132-c4f3d25ed901 in the Event Log or use 
the command line Get-AppPackageLog -ActivityID f38787bd-5ed2-0005-d132-c4f3d25ed901
At line:1 char:1
+ Add-AppxPackage -Path 'C:\Users\camde\source\repos\SwimLauncher\SwimL ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (C:\Users\camde\...ppxManifest.xml:String) [Add-AppxPackage], IOException
    + FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageCommand

I am not sure what this means by saying the manifest is not in the package root, as it indeed is as shown in the attached image. I verified the path is correct as well.
image.png
Was this page helpful?