Skip to content

Commit

Permalink
Merge pull request #3 from oqtane/master
Browse files Browse the repository at this point in the history
sync
  • Loading branch information
sbwalker authored Apr 12, 2020
2 parents dbcb973 + f792e7e commit f763fbd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
22 changes: 17 additions & 5 deletions Oqtane.Server/Infrastructure/InstallationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -66,6 +78,7 @@ public void InstallPackages(string folders, bool restart)
{
frameworkversion = node.Attributes["version"].Value;
}

reader.Close();
}
}
Expand Down Expand Up @@ -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()
Expand Down
11 changes: 4 additions & 7 deletions Oqtane.Server/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}

Expand Down Expand Up @@ -155,11 +156,7 @@ public void ConfigureServices(IServiceCollection services)
services.AddSingleton<DatabaseManager>();

// 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<IInstallationManager>();
InstallationManager.InstallPackages("Modules,Themes", false);
InstallationManager.UnpackPackages("Modules,Themes", _webRoot);

// register transient scoped core services
services.AddTransient<IModuleDefinitionRepository, ModuleDefinitionRepository>();
Expand Down

0 comments on commit f763fbd

Please sign in to comment.