From 3528b8c6744c0d0ab0d77835af9fa611b2d8ec3c Mon Sep 17 00:00:00 2001 From: sbwalker Date: Fri, 22 Nov 2024 12:13:45 -0500 Subject: [PATCH] fix #4848 - remove assemblies from /bin which have been moved to /bin/refs in .NET 9 --- .../Infrastructure/UpgradeManager.cs | 53 ++++++++++++++++++- Oqtane.Shared/Shared/Constants.cs | 4 +- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/Oqtane.Server/Infrastructure/UpgradeManager.cs b/Oqtane.Server/Infrastructure/UpgradeManager.cs index 79e3ae92..633ea9ef 100644 --- a/Oqtane.Server/Infrastructure/UpgradeManager.cs +++ b/Oqtane.Server/Infrastructure/UpgradeManager.cs @@ -69,6 +69,9 @@ namespace Oqtane.Infrastructure case "5.2.1": Upgrade_5_2_1(tenant, scope); break; + case "6.0.1": + Upgrade_6_0_1(tenant, scope); + break; } } } @@ -371,7 +374,7 @@ namespace Oqtane.Infrastructure try { // delete legacy Views assemblies which will cause startup errors due to missing HostModel - // note that the following files will be deleted however the framework has already started up so a restart will be required + // note that the following files will be deleted however the framework has already started up so another restart will be required var binFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); var filepath = Path.Combine(binFolder, "Oqtane.Server.Views.dll"); if (System.IO.File.Exists(filepath)) System.IO.File.Delete(filepath); @@ -441,6 +444,54 @@ namespace Oqtane.Infrastructure AddPagesToSites(scope, tenant, pageTemplates); } + private void Upgrade_6_0_1(Tenant tenant, IServiceScope scope) + { + // assemblies which have been relocated to the bin/refs folder in .NET 9 + string[] assemblies = { + "Microsoft.AspNetCore.Authorization.dll", + "Microsoft.AspNetCore.Components.Authorization.dll", + "Microsoft.AspNetCore.Components.dll", + "Microsoft.AspNetCore.Components.Forms.dll", + "Microsoft.AspNetCore.Components.Web.dll", + "Microsoft.AspNetCore.Cryptography.Internal.dll", + "Microsoft.AspNetCore.Cryptography.KeyDerivation.dll", + "Microsoft.AspNetCore.Metadata.dll", + "Microsoft.Extensions.Caching.Memory.dll", + "Microsoft.Extensions.Configuration.Binder.dll", + "Microsoft.Extensions.Configuration.FileExtensions.dll", + "Microsoft.Extensions.Configuration.Json.dll", + "Microsoft.Extensions.DependencyInjection.Abstractions.dll", + "Microsoft.Extensions.DependencyInjection.dll", + "Microsoft.Extensions.Diagnostics.Abstractions.dll", + "Microsoft.Extensions.Diagnostics.dll", + "Microsoft.Extensions.Http.dll", + "Microsoft.Extensions.Identity.Core.dll", + "Microsoft.Extensions.Identity.Stores.dll", + "Microsoft.Extensions.Localization.Abstractions.dll", + "Microsoft.Extensions.Localization.dll", + "Microsoft.Extensions.Logging.Abstractions.dll", + "Microsoft.Extensions.Logging.dll", + "Microsoft.Extensions.Options.dll", + "Microsoft.JSInterop.dll", + "System.Text.Json.dll" + }; + + foreach (var assembly in assemblies) + { + try + { + var binFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + var filepath = Path.Combine(binFolder, assembly); + if (System.IO.File.Exists(filepath)) System.IO.File.Delete(filepath); + } + catch (Exception ex) + { + // error deleting asesmbly + Debug.WriteLine($"Oqtane Error: 6.0.1 Upgrade Error Removing {assembly} - {ex}"); + } + } + } + private void AddPagesToSites(IServiceScope scope, Tenant tenant, List pageTemplates) { var tenants = scope.ServiceProvider.GetRequiredService(); diff --git a/Oqtane.Shared/Shared/Constants.cs b/Oqtane.Shared/Shared/Constants.cs index aa83db6c..7f56d72f 100644 --- a/Oqtane.Shared/Shared/Constants.cs +++ b/Oqtane.Shared/Shared/Constants.cs @@ -4,8 +4,8 @@ namespace Oqtane.Shared { public class Constants { - public static readonly string Version = "6.0.0"; - public const string ReleaseVersions = "1.0.0,1.0.1,1.0.2,1.0.3,1.0.4,2.0.0,2.0.1,2.0.2,2.1.0,2.2.0,2.3.0,2.3.1,3.0.0,3.0.1,3.0.2,3.0.3,3.1.0,3.1.1,3.1.2,3.1.3,3.1.4,3.2.0,3.2.1,3.3.0,3.3.1,3.4.0,3.4.1,3.4.2,3.4.3,4.0.0,4.0.1,4.0.2,4.0.3,4.0.4,4.0.5,4.0.6,5.0.0,5.0.1,5.0.2,5.0.3,5.1.0,5.1.1,5.1.2,5.2.0,5.2.1,5.2.2,5.2.3,5.2.4,6.0.0"; + public static readonly string Version = "6.0.1"; + public const string ReleaseVersions = "1.0.0,1.0.1,1.0.2,1.0.3,1.0.4,2.0.0,2.0.1,2.0.2,2.1.0,2.2.0,2.3.0,2.3.1,3.0.0,3.0.1,3.0.2,3.0.3,3.1.0,3.1.1,3.1.2,3.1.3,3.1.4,3.2.0,3.2.1,3.3.0,3.3.1,3.4.0,3.4.1,3.4.2,3.4.3,4.0.0,4.0.1,4.0.2,4.0.3,4.0.4,4.0.5,4.0.6,5.0.0,5.0.1,5.0.2,5.0.3,5.1.0,5.1.1,5.1.2,5.2.0,5.2.1,5.2.2,5.2.3,5.2.4,6.0.0,6.0.1"; public const string PackageId = "Oqtane.Framework"; public const string ClientId = "Oqtane.Client"; public const string UpdaterPackageId = "Oqtane.Updater";