diff --git a/Oqtane.Server/Infrastructure/InstallationManager.cs b/Oqtane.Server/Infrastructure/InstallationManager.cs index 3479861d4..a85fdcc71 100644 --- a/Oqtane.Server/Infrastructure/InstallationManager.cs +++ b/Oqtane.Server/Infrastructure/InstallationManager.cs @@ -25,13 +25,25 @@ public InstallationManager(IHostApplicationLifetime hostApplicationLifetime, IWe } public void InstallPackages(string folders, bool restart) + { + var webRootPath = _environment.WebRootPath; + + var install = UnpackPackages(folders, webRootPath); + + if (install && restart) + { + RestartApplication(); + } + } + + public static bool UnpackPackages(string folders, string webRootPath) { bool install = false; string binFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location); foreach (string folder in folders.Split(',')) { - string sourceFolder = Path.Combine(_environment.WebRootPath, folder); + string sourceFolder = Path.Combine(webRootPath, folder); // create folder if it does not exist if (!Directory.Exists(sourceFolder)) @@ -66,6 +78,7 @@ public void InstallPackages(string folders, bool restart) { frameworkversion = node.Attributes["version"].Value; } + reader.Close(); } } @@ -95,22 +108,21 @@ public void InstallPackages(string folders, bool restart) { Directory.CreateDirectory(Path.GetDirectoryName(filename)); } + entry.ExtractToFile(filename, true); break; } } } } + // remove package File.Delete(packagename); install = true; } } - if (install && restart) - { - RestartApplication(); - } + return install; } public void UpgradeFramework() diff --git a/Oqtane.Server/Startup.cs b/Oqtane.Server/Startup.cs index f2ed34bb3..777686097 100644 --- a/Oqtane.Server/Startup.cs +++ b/Oqtane.Server/Startup.cs @@ -25,14 +25,15 @@ namespace Oqtane public class Startup { public IConfigurationRoot Configuration { get; } - + private string _webRoot; + public Startup(IWebHostEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); Configuration = builder.Build(); - + _webRoot = env.WebRootPath; AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(env.ContentRootPath, "Data")); } @@ -155,11 +156,7 @@ public void ConfigureServices(IServiceCollection services) services.AddSingleton(); // install any modules or themes ( this needs to occur BEFORE the assemblies are loaded into the app domain ) - #pragma warning disable ASP0000 - ServiceProvider sp = services.BuildServiceProvider(); - #pragma warning restore ASP0000 - var InstallationManager = sp.GetRequiredService(); - InstallationManager.InstallPackages("Modules,Themes", false); + InstallationManager.UnpackPackages("Modules,Themes", _webRoot); // register transient scoped core services services.AddTransient();