C
C#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);
}
}
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

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.
S
swim415d ago
the issue might be that it wants this to be in the WindowsApps folder, while the goal of my program is to be able to have multiple versions installed of this app at custom locations
A
Accord414d ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.