nuget module installation fix
This commit is contained in:
		@ -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)
 | 
			
		||||
 | 
			
		||||
@ -107,7 +107,7 @@ namespace Oqtane.Infrastructure
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (install && restart)
 | 
			
		||||
            if (install)
 | 
			
		||||
            {
 | 
			
		||||
                if (restart)
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
@ -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();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -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();
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user