This repository has been archived by the owner on Jan 26, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from Drommedhar/xbox_fix
Xbox fix
- Loading branch information
Showing
5 changed files
with
168 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
using System.IO; | ||
using System.Xml.Linq; | ||
using Windows.Management.Deployment; | ||
|
||
namespace DLSSUpdater.Helpers | ||
{ | ||
public static class WindowsAppHelper | ||
{ | ||
public static XDocument? InitXDocumentFromManifest(string manifestPath, out XNamespace? uap) | ||
{ | ||
XDocument? xmlDoc = null; | ||
if (!File.Exists(manifestPath)) | ||
{ | ||
uap = null; | ||
return null; | ||
} | ||
|
||
// Load the XML file | ||
xmlDoc = XDocument.Load(manifestPath); | ||
|
||
// Extract the "uap" namespace dynamically from the XML | ||
uap = xmlDoc.Root?.GetNamespaceOfPrefix("uap"); | ||
|
||
return xmlDoc; | ||
} | ||
|
||
public static string? GetIdentityNameFromXml(XDocument xmlDoc, XNamespace ns) | ||
{ | ||
// Find the package element | ||
var packageElement = xmlDoc | ||
.Descendants("{http://schemas.microsoft.com/appx/manifest/foundation/windows10}Package") | ||
.FirstOrDefault(); | ||
|
||
// Get the identity name from the Identity element | ||
string? name = packageElement? | ||
.Descendants("{http://schemas.microsoft.com/appx/manifest/foundation/windows10}Identity") | ||
.FirstOrDefault()?.Attribute("Name")?.Value; | ||
|
||
return name; | ||
} | ||
|
||
public static string? GetDisplayNameFromXml(XDocument xmlDoc, XNamespace uap) | ||
{ | ||
string? displayName = null; | ||
|
||
// Query the DisplayName inside uap:VisualElements | ||
displayName = xmlDoc | ||
.Descendants(uap + "VisualElements") | ||
.FirstOrDefault()?.Attribute("DisplayName")?.Value; | ||
|
||
if (displayName is not null && displayName.Contains("AppDisplayName") || displayName is null) | ||
{ | ||
displayName = xmlDoc.Descendants("{http://schemas.microsoft.com/appx/manifest/foundation/windows10}DisplayName") | ||
.FirstOrDefault()?.Value; | ||
} | ||
|
||
return displayName; | ||
} | ||
|
||
public static List<ApplicationInfo> GetInstalledAppsFromWindowsStore() | ||
{ | ||
List<ApplicationInfo> apps = new List<ApplicationInfo>(); | ||
PackageManager packageManager = new PackageManager(); | ||
|
||
// Query the package manager to get every packages installed. | ||
var packages = packageManager.FindPackagesForUserWithPackageTypes( | ||
string.Empty, | ||
PackageTypes.Main | ||
); | ||
|
||
foreach (var package in packages) | ||
{ | ||
try | ||
{ | ||
if (package.InstalledLocation?.Path != null) | ||
{ | ||
var manifestPath = Path.Combine(package.InstalledLocation?.Path!, "appxmanifest.xml"); | ||
var xmlDoc = InitXDocumentFromManifest(manifestPath, out var uap); | ||
if (xmlDoc is not null && uap is not null) | ||
{ | ||
var identityName = GetIdentityNameFromXml(xmlDoc, uap); | ||
if(identityName is not null) | ||
{ | ||
// Associate the correct name to the one found in the manifest | ||
apps.Add(new ApplicationInfo | ||
{ | ||
displayName = package.DisplayName, | ||
identityName = identityName | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine(ex.ToString()); | ||
} | ||
} | ||
|
||
return apps; | ||
} | ||
} | ||
|
||
public class ApplicationInfo | ||
{ | ||
public string displayName { get; set; } | ||
Check warning on line 106 in DlssUpdater/Helpers/WindowsAppHelper.cs GitHub Actions / build (x64)
|
||
public string identityName { get; set; } | ||
Check warning on line 107 in DlssUpdater/Helpers/WindowsAppHelper.cs GitHub Actions / build (x64)
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"version": "2.0.5.4" | ||
"version": "2.0.5.5" | ||
} |