From f7cf25c4bb78662fc97da33bb225e28dca968528 Mon Sep 17 00:00:00 2001 From: sbwalker Date: Thu, 30 Jan 2025 08:39:49 -0500 Subject: [PATCH] fix upgrade issue which can occur in development environments --- .../Infrastructure/UpgradeManager.cs | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Oqtane.Server/Infrastructure/UpgradeManager.cs b/Oqtane.Server/Infrastructure/UpgradeManager.cs index b32adaeb..7d386eb6 100644 --- a/Oqtane.Server/Infrastructure/UpgradeManager.cs +++ b/Oqtane.Server/Infrastructure/UpgradeManager.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Oqtane.Models; using Oqtane.Repository; @@ -507,18 +508,22 @@ namespace Oqtane.Infrastructure private void RemoveAssemblies(string[] assemblies, string version) { - foreach (var assembly in assemblies) + // in a development environment assemblies cannot be removed as the debugger runs fron /bin folder and locks the files + if (!_environment.IsDevelopment()) { - try + foreach (var assembly in assemblies) { - 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 - _filelogger.LogError(Utilities.LogMessage(this, $"Oqtane Error: {version} Upgrade Error Removing {assembly} - {ex}")); + 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 + _filelogger.LogError(Utilities.LogMessage(this, $"Oqtane Error: {version} Upgrade Error Removing {assembly} - {ex}")); + } } } }