Skip to content

Commit

Permalink
[Upgrader] Skip specific package prefixed with Stride from auto-upgra…
Browse files Browse the repository at this point in the history
…de (#2093)
  • Loading branch information
Doprez committed Jan 21, 2024
1 parent 6e8e532 commit b3f6b96
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
21 changes: 21 additions & 0 deletions sources/assets/Stride.Core.Assets/StridePackagesToSkipUpgrade.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
using System.Collections.Generic;

namespace Stride.Core.Assets;

public static class StridePackagesToSkipUpgrade
{
public static string[] PackageNames =
[
"Stride.Awesome.Shaders",
// In case other packages are added with the community namespace,
"Stride.Community.",
"Stride.CommunityToolkit",
"Stride.GraphX.WPF.Controls",
"Stride.GNU.Gettext",
"Stride.OpenTK",
"Stride.Metrics",
"Stride.BepuPhysics",
];
}
19 changes: 18 additions & 1 deletion sources/engine/Stride.Assets/StridePackageUpgrader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,25 @@ public override bool UpgradeBeforeAssembliesLoaded(PackageLoadParameters loadPar
{
var project = VSProjectHelper.LoadProject(projectFullPath.ToWindowsPath());
var isProjectDirty = false;

List<Microsoft.Build.Evaluation.ProjectItem> packageReferences = new();
foreach(var package in project.GetItems("PackageReference"))
{
bool addPackage = true;
for (int i = 0; i < StridePackagesToSkipUpgrade.PackageNames.Length; i++)
{
if (package.EvaluatedInclude.StartsWith(StridePackagesToSkipUpgrade.PackageNames[i])
|| StridePackagesToSkipUpgrade.PackageNames[i].Equals(package.EvaluatedInclude))
{
addPackage = false;
}
}

var packageReferences = project.GetItems("PackageReference").ToList();
if(addPackage)
{
packageReferences.Add(package);
}
}

// Remove Stride reference for older executable projects (it was necessary in the past due to runtime.json)
if (dependency.Version.MinVersion < new PackageVersion("4.1.0.0")
Expand Down

0 comments on commit b3f6b96

Please sign in to comment.