0
0
Quellcode durchsuchen

升级.net7启动器

zhontai vor 2 Jahren
Ursprung
Commit
9bde7965a9

+ 4 - 4
src/hosts/ZhonTai.Host/Configs/dbconfig.json

@@ -64,11 +64,11 @@
   //使用FreeSqlCloud访问  freeSqlCloud.Use(DbKeys.AppDb);
   "dbs": [
     //{
-    //  "key": "admindb",
+    //  "key": "appdb",
     //  "type": "Sqlite",
-    //  "syncStructure": true,
-    //  "syncData": true,
-    //  "connectionString": "Data Source=|DataDirectory|\\db\\admindb.db; Pooling=true;Min Pool Size=1",
+    //  "syncStructure": false,
+    //  "syncData": false,
+    //  "connectionString": "Data Source=|DataDirectory|\\appdb.db; Pooling=true;Min Pool Size=1",
     //  "providerType": ""
     //}
   ]

+ 2 - 4
src/hosts/ZhonTai.Host/appsettings.json

@@ -1,10 +1,8 @@
 {
   "Logging": {
-    "IncludeScopes": false,
     "LogLevel": {
-      "Default": "Trace",
-      "Microsoft": "Warning",
-      "Microsoft.Hosting.Lifetime": "Information"
+      "Default": "Information",
+      "Microsoft.AspNetCore": "Warning"
     }
   },
   "AllowedHosts": "*"

+ 13 - 19
src/platform/ZhonTai.Admin/Core/HostApp.cs

@@ -74,21 +74,6 @@ public class HostApp
         //使用NLog日志
         builder.Host.UseNLog();
 
-        //添加配置
-        builder.Host.ConfigureAppConfiguration((context, builder) =>
-        {
-            builder.AddJsonFile("./Configs/ratelimitconfig.json", optional: true, reloadOnChange: true);
-            if (context.HostingEnvironment.EnvironmentName.NotNull())
-            {
-                builder.AddJsonFile($"./Configs/ratelimitconfig.{context.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true);
-            }
-            builder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
-            if (context.HostingEnvironment.EnvironmentName.NotNull())
-            {
-                builder.AddJsonFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true);
-            }
-        });
-
         var services = builder.Services;
         var env = builder.Environment;
         var configuration = builder.Configuration;
@@ -96,6 +81,18 @@ public class HostApp
         var configHelper = new ConfigHelper();
         var appConfig = ConfigHelper.Get<AppConfig>("appconfig", env.EnvironmentName) ?? new AppConfig();
 
+        //添加配置
+        builder.Configuration.AddJsonFile("./Configs/ratelimitconfig.json", optional: true, reloadOnChange: true);
+        if (env.EnvironmentName.NotNull())
+        {
+            builder.Configuration.AddJsonFile($"./Configs/ratelimitconfig.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
+        }
+        builder.Configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
+        if (env.EnvironmentName.NotNull())
+        {
+            builder.Configuration.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
+        }
+
         //应用配置
         services.AddSingleton(appConfig);
 
@@ -629,10 +626,7 @@ public class HostApp
         });
 
         //配置端点
-        app.UseEndpoints(endpoints =>
-        {
-            endpoints.MapControllers();
-        });
+        app.MapControllers();
 
         _hostAppOptions?.ConfigureMiddleware?.Invoke(hostAppMiddlewareContext);