Skip to content
Permalink
Browse files

[Assets] PackageUpgrader: react to multiple package names (to support…

… renames and/or package splits in multiple parts)
  • Loading branch information
xen2 committed Dec 14, 2018
1 parent 73f6cab commit 2e0bbe3f005c20779af718c57adab5a09b6efe12
@@ -542,7 +542,8 @@ private static void RegisterAssetAssembly(Assembly assembly)
{
var packageUpgrader = (PackageUpgrader)Activator.CreateInstance(type);
packageUpgrader.Attribute = packageUpgraderAttribute;
RegisteredPackageUpgraders[packageUpgraderAttribute.PackageName] = packageUpgrader;
foreach (var packageName in packageUpgraderAttribute.PackageNames)
RegisteredPackageUpgraders[packageName] = packageUpgrader;
}
catch (Exception ex)
{
@@ -159,6 +159,10 @@ private async Task PreLoadPackageDependencies(ILogger log, SolutionProject proje
var packageUpgrader = AssetRegistry.GetPackageUpgrader(dependencyName);
if (packageUpgrader != null)
{
// Check if this upgrader has already been added due to another package reference
if (pendingPackageUpgrades.Any(pendingPackageUpgrade => pendingPackageUpgrade.PackageUpgrader == packageUpgrader))
continue;

// Check if upgrade is necessary
if (dependencyVersion.MinVersion >= packageUpgrader.Attribute.UpdatedVersionRange.MinVersion)
{
@@ -18,15 +18,15 @@ public class PackageUpgraderAttribute : Attribute
{
private readonly PackageVersionRange updatedVersionRange;

public string PackageName { get; private set; }
public string[] PackageNames { get; private set; }

public PackageVersion PackageMinimumVersion { get; private set; }

public PackageVersionRange UpdatedVersionRange { get { return updatedVersionRange; } }

public PackageUpgraderAttribute(string packageName, string packageMinimumVersion, string packageUpdatedVersionRange)
public PackageUpgraderAttribute(string[] packageNames, string packageMinimumVersion, string packageUpdatedVersionRange)
{
PackageName = packageName;
PackageNames = packageNames;
PackageMinimumVersion = new PackageVersion(packageMinimumVersion);
PackageVersionRange.TryParse(packageUpdatedVersionRange, out this.updatedVersionRange);
}
@@ -25,7 +25,7 @@
namespace Xenko.Assets
{
#if XENKO_SUPPORT_BETA_UPGRADE
[PackageUpgrader(XenkoConfig.PackageName, "1.10.0-alpha01", CurrentVersion)]
[PackageUpgrader(new[] { XenkoConfig.PackageName, "Xenko.Core", "Xenko.Engine" }, "1.10.0-alpha01", CurrentVersion)]
#else
[PackageUpgrader(XenkoConfig.PackageName, "2.0.0.0", CurrentVersion)]
#endif

0 comments on commit 2e0bbe3

Please sign in to comment.
You can’t perform that action at this time.