Skip to content
Permalink
Browse files

[Assets] Fix package upgrader

  • Loading branch information
xen2 committed Nov 1, 2018
1 parent 1f269ac commit 6c82ca5e10727a779bc2f5bbe77e7f5948701b3b
Showing with 20 additions and 7 deletions.
  1. +20 −7 sources/engine/Xenko.Assets/XenkoPackageUpgrader.cs
@@ -439,26 +439,39 @@ public override bool UpgradeBeforeAssembliesLoaded(PackageLoadParameters loadPar
var xenkoReference = packageReferences.FirstOrDefault(packageReference => packageReference.EvaluatedInclude == "Xenko");
if (xenkoReference != null)
{
var items = new List<Microsoft.Build.Evaluation.ProjectItem> { xenkoReference };

// Turn Xenko reference into Xenko.Engine
xenkoReference.UnevaluatedInclude = "Xenko.Engine";
xenkoReference.SetMetadataValue("Version", CurrentVersion);

// Add plugins (old Xenko is equivalent to a meta package with all plugins)
project.AddItem("PackageReference", "Xenko.Video", new[] { new KeyValuePair<string, string>("Version", CurrentVersion), new KeyValuePair<string, string>("PrivateAssets", "contentfiles;analyzers") });
project.AddItem("PackageReference", "Xenko.Physics", new[] { new KeyValuePair<string, string>("Version", CurrentVersion), new KeyValuePair<string, string>("PrivateAssets", "contentfiles;analyzers") });
project.AddItem("PackageReference", "Xenko.Navigation", new[] { new KeyValuePair<string, string>("Version", CurrentVersion), new KeyValuePair<string, string>("PrivateAssets", "contentfiles;analyzers") });
project.AddItem("PackageReference", "Xenko.Particles", new[] { new KeyValuePair<string, string>("Version", CurrentVersion), new KeyValuePair<string, string>("PrivateAssets", "contentfiles;analyzers") });
project.AddItem("PackageReference", "Xenko.UI", new[] { new KeyValuePair<string, string>("Version", CurrentVersion), new KeyValuePair<string, string>("PrivateAssets", "contentfiles;analyzers") });
items.AddRange(project.AddItem("PackageReference", "Xenko.Video", new[] { new KeyValuePair<string, string>("Version", CurrentVersion), new KeyValuePair<string, string>("PrivateAssets", "contentfiles;analyzers") }));
items.AddRange(project.AddItem("PackageReference", "Xenko.Physics", new[] { new KeyValuePair<string, string>("Version", CurrentVersion), new KeyValuePair<string, string>("PrivateAssets", "contentfiles;analyzers") }));
items.AddRange(project.AddItem("PackageReference", "Xenko.Navigation", new[] { new KeyValuePair<string, string>("Version", CurrentVersion), new KeyValuePair<string, string>("PrivateAssets", "contentfiles;analyzers") }));
items.AddRange(project.AddItem("PackageReference", "Xenko.Particles", new[] { new KeyValuePair<string, string>("Version", CurrentVersion), new KeyValuePair<string, string>("PrivateAssets", "contentfiles;analyzers") }));
items.AddRange(project.AddItem("PackageReference", "Xenko.UI", new[] { new KeyValuePair<string, string>("Version", CurrentVersion), new KeyValuePair<string, string>("PrivateAssets", "contentfiles;analyzers") }));

// Asset compiler
project.AddItem("PackageReference", "Xenko.Core.Assets.CompilerApp", new[] { new KeyValuePair<string, string>("Version", CurrentVersion), new KeyValuePair<string, string>("PrivateAssets", "contentfiles;analyzers"), new KeyValuePair<string, string>("IncludeAssets", "build") });
items.AddRange(project.AddItem("PackageReference", "Xenko.Core.Assets.CompilerApp", new[] { new KeyValuePair<string, string>("Version", CurrentVersion), new KeyValuePair<string, string>("PrivateAssets", "contentfiles;analyzers"), new KeyValuePair<string, string>("IncludeAssets", "build") }));

foreach (var item in items)
{
foreach (var metadata in item.Metadata)
metadata.Xml.ExpressedAsAttribute = true;
}

isProjectDirty = true;
}
}

foreach (var packageReference in packageReferences)
{
if (packageReference.EvaluatedInclude.StartsWith("Xenko.") && packageReference.GetMetadataValue("Version") != CurrentVersion)
{
packageReference.SetMetadataValue("Version", CurrentVersion);
packageReference.SetMetadataValue("Version", CurrentVersion).Xml.ExpressedAsAttribute = true;
foreach (var metadata in packageReference.Metadata)
metadata.Xml.ExpressedAsAttribute = true;
isProjectDirty = true;
}
}

0 comments on commit 6c82ca5

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