From 0c6726e3f726094b33961cc11821fc8fd87510f0 Mon Sep 17 00:00:00 2001 From: sbwalker Date: Tue, 26 Mar 2024 14:26:55 -0400 Subject: [PATCH] fix upgrade issue by removing legacy Views assembly --- Oqtane.Server/Infrastructure/UpgradeManager.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Oqtane.Server/Infrastructure/UpgradeManager.cs b/Oqtane.Server/Infrastructure/UpgradeManager.cs index 1f30cbc09..3f0dd0f6e 100644 --- a/Oqtane.Server/Infrastructure/UpgradeManager.cs +++ b/Oqtane.Server/Infrastructure/UpgradeManager.cs @@ -8,6 +8,7 @@ using System.Diagnostics; using System.IO; using System.Linq; +using System.Reflection; namespace Oqtane.Infrastructure { @@ -365,7 +366,24 @@ private void Upgrade_5_1_0(Tenant tenant, IServiceScope scope) { _configManager.AddOrUpdateSetting("RenderMode", rendermode.Replace("Prerendered", ""), true); } + + 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 + 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); + filepath = Path.Combine(binFolder, "Oqtane.Server.Views.pdb"); + if (System.IO.File.Exists(filepath)) System.IO.File.Delete(filepath); + } + catch (Exception ex) + { + // error deleting file + Debug.WriteLine($"Oqtane Error: Error In 5.1.0 Upgrade Logic - {ex}"); + } } + } } }