Merge pull request #351 from chlupac/InstallModuleBug

nuget module installation fix
This commit is contained in:
Shaun Walker 2020-04-11 11:06:34 -04:00 committed by GitHub
commit 139e33b539
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)
{
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();
app.UseBlazorFrameworkFiles();