nuget module installation fix

This commit is contained in:
Pavel Vesely 2020-04-07 11:21:33 +02:00
parent b15ff4732c
commit 3fc7e78e56
4 changed files with 13 additions and 10 deletions

View File

@ -74,7 +74,6 @@ namespace Oqtane.Infrastructure
}
}
public bool IsInstalled
{
get
@ -212,6 +211,8 @@ namespace Oqtane.Infrastructure
private static void ModuleMigration(Assembly assembly, string connectionString)
{
Console.WriteLine($"Migrating assembly {assembly.FullName}");
var dbUpgradeConfig = DeployChanges.To.SqlDatabase(connectionString)
.WithScriptsEmbeddedInAssembly(assembly); // scripts must be included as Embedded Resources
var dbUpgrade = dbUpgradeConfig.Build();
@ -238,17 +239,19 @@ namespace Oqtane.Infrastructure
}
}
}
private static void TenantMigration(string connectionString, string dataDirectory)
{
Console.WriteLine("Tenant migration");
var assemblies = AppDomain.CurrentDomain.GetAssemblies()
.Where(item => item.FullName != null && item.FullName.Contains(".Module.")).ToArray();
.Where(item => item.FullName != null && item.FullName.ToLower().Contains(".module.")).ToArray();
// get tenants
using (var db = new InstallationContext(connectionString))
{
foreach (var tenant in db.Tenant.ToList())
{
Console.WriteLine($"Migrating tenant {tenant.Name}");
connectionString = NormalizeConnectionString(tenant.DBConnectionString, dataDirectory);
// upgrade framework
var dbUpgradeConfig = DeployChanges.To.SqlDatabase(connectionString)

View File

@ -107,7 +107,7 @@ namespace Oqtane.Infrastructure
}
}
if (install && restart)
if (install)
{
if (restart)
{

View File

@ -16,8 +16,11 @@ namespace Oqtane.Server
var host = BuildWebHost(args);
using (var serviceScope = host.Services.GetRequiredService<IServiceScopeFactory>().CreateScope())
{
var manager = serviceScope.ServiceProvider.GetService<DatabaseManager>();
manager.StartupMigration();
var installationManager = serviceScope.ServiceProvider.GetService<IInstallationManager>();
// install any modules or themes stored in nugget, then restart app to ensure all is loaded in order
installationManager.InstallPackages("Modules,Themes", true);
var databaseManager = serviceScope.ServiceProvider.GetService<DatabaseManager>();
databaseManager.StartupMigration();
}
host.Run();
}

View File

@ -201,7 +201,7 @@ namespace Oqtane
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IInstallationManager installationManager)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IInstallationManager installationManager, DatabaseManager databaseManager)
{
if (env.IsDevelopment())
{
@ -214,9 +214,6 @@ namespace Oqtane
app.UseHsts();
}
// install any modules or themes
installationManager.InstallPackages("Modules,Themes", false);
app.UseHttpsRedirection();
app.UseStaticFiles();