Skip to content

Commit

Permalink
Get ARP entries from MSI database
Browse files Browse the repository at this point in the history
  • Loading branch information
vedantmgoyal9 committed Sep 5, 2024
1 parent 7dfac18 commit 2f91e41
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions src/WingetCreateCore/Common/PackageParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,21 +477,36 @@ private static void UpdateInstallerMetadata(Installer existingInstaller, Install

if (existingInstaller.AppsAndFeaturesEntries != null && newInstaller.AppsAndFeaturesEntries != null)
{
// When --display-version is provided, AppsAndFeaturesEntries for the new installer will not be null
// and will contain a single entry.
string newDisplayVersion = newInstaller.AppsAndFeaturesEntries.FirstOrDefault().DisplayVersion;

// Set DisplayVersion for each new installer if it exists in the corresponding existing installer.
foreach (var existingAppsAndFeaturesEntry in existingInstaller.AppsAndFeaturesEntries)
{
if (existingAppsAndFeaturesEntry.DisplayVersion != null)
if (existingAppsAndFeaturesEntry.DisplayName != null && newInstaller.AppsAndFeaturesEntries.FirstOrDefault().DisplayName != null)
{
existingAppsAndFeaturesEntry.DisplayName = newInstaller.AppsAndFeaturesEntries.FirstOrDefault().DisplayName;
}

if (existingAppsAndFeaturesEntry.DisplayVersion != null && newInstaller.AppsAndFeaturesEntries.FirstOrDefault().DisplayVersion != null)
{
existingAppsAndFeaturesEntry.DisplayVersion = newDisplayVersion ?? existingAppsAndFeaturesEntry.DisplayVersion;
existingAppsAndFeaturesEntry.DisplayVersion = newInstaller.AppsAndFeaturesEntries.FirstOrDefault().DisplayVersion;
}

// Break on first match to avoid setting DisplayVersion for all entries.
// We do not support updating multiple DisplayVersions under the same installer.
break;
if (existingAppsAndFeaturesEntry.Publisher != null && newInstaller.AppsAndFeaturesEntries.FirstOrDefault().Publisher != null)
{
existingAppsAndFeaturesEntry.Publisher = newInstaller.AppsAndFeaturesEntries.FirstOrDefault().Publisher;
}

if (existingAppsAndFeaturesEntry.ProductCode != null && newInstaller.AppsAndFeaturesEntries.FirstOrDefault().ProductCode != null)
{
existingAppsAndFeaturesEntry.ProductCode = newInstaller.AppsAndFeaturesEntries.FirstOrDefault().ProductCode;
}

if (existingAppsAndFeaturesEntry.UpgradeCode != null && newInstaller.AppsAndFeaturesEntries.FirstOrDefault().UpgradeCode != null)
{
existingAppsAndFeaturesEntry.UpgradeCode = newInstaller.AppsAndFeaturesEntries.FirstOrDefault().UpgradeCode;
}

// Break on first match to avoid setting DisplayVersion for all entries.
// We do not support updating multiple DisplayVersions under the same installer.
break;
}
}
}
Expand Down Expand Up @@ -891,6 +906,17 @@ private static bool ParseMsi(string path, Installer baseInstaller, Manifests man
}

baseInstaller.ProductCode = properties.FirstOrDefault(p => p.Property == "ProductCode")?.Value;
baseInstaller.AppsAndFeaturesEntries = new List<AppsAndFeaturesEntry>
{
new AppsAndFeaturesEntry
{
DisplayName = properties.FirstOrDefault(p => p.Property == "ProductName")?.Value,
DisplayVersion = properties.FirstOrDefault(p => p.Property == "ProductVersion")?.Value,
Publisher = properties.FirstOrDefault(p => p.Property == "Manufacturer")?.Value,
ProductCode = properties.FirstOrDefault(p => p.Property == "ProductCode")?.Value,
UpgradeCode = properties.FirstOrDefault(p => p.Property == "UpgradeCode")?.Value,
},
};

string archString = database.SummaryInfo.Template.Split(';').First();

Expand Down

0 comments on commit 2f91e41

Please sign in to comment.