diff options
author | crupest <crupest@outlook.com> | 2021-01-23 01:38:09 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-01-23 01:38:09 +0800 |
commit | 15ebe6a7197a3b7761ff153f70812d0366036cec (patch) | |
tree | 0c09034805e0feaf8b103183fda6f3c43398cc88 /BackEnd | |
parent | 011761c5603e7275a20a2597f9f0b03c18c7d0fd (diff) | |
parent | d2696cab01bea5fba0c00b907343e8052adacd74 (diff) | |
download | timeline-15ebe6a7197a3b7761ff153f70812d0366036cec.tar.gz timeline-15ebe6a7197a3b7761ff153f70812d0366036cec.tar.bz2 timeline-15ebe6a7197a3b7761ff153f70812d0366036cec.zip |
Merge branch 'master' into search
Diffstat (limited to 'BackEnd')
-rw-r--r-- | BackEnd/.vscode/launch.json | 36 | ||||
-rw-r--r-- | BackEnd/.vscode/tasks.json | 42 | ||||
-rw-r--r-- | BackEnd/Timeline/Program.cs | 51 | ||||
-rw-r--r-- | BackEnd/Timeline/Properties/launchSettings.json | 9 |
4 files changed, 109 insertions, 29 deletions
diff --git a/BackEnd/.vscode/launch.json b/BackEnd/.vscode/launch.json new file mode 100644 index 00000000..9eef271c --- /dev/null +++ b/BackEnd/.vscode/launch.json @@ -0,0 +1,36 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/Timeline/bin/Debug/net5.0/Timeline.dll", + "args": [], + "cwd": "${workspaceFolder}/Timeline", + "stopAtEntry": false, + // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bNow listening on:\\s+(https?://\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +}
\ No newline at end of file diff --git a/BackEnd/.vscode/tasks.json b/BackEnd/.vscode/tasks.json new file mode 100644 index 00000000..a60ac3a7 --- /dev/null +++ b/BackEnd/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/Timeline/Timeline.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/Timeline/Timeline.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "${workspaceFolder}/Timeline/Timeline.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +}
\ No newline at end of file diff --git a/BackEnd/Timeline/Program.cs b/BackEnd/Timeline/Program.cs index 87e330a2..1f0f72b9 100644 --- a/BackEnd/Timeline/Program.cs +++ b/BackEnd/Timeline/Program.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.Resources;
@@ -10,34 +11,38 @@ using Timeline.Services; namespace Timeline
{
- public static class Program
+ public static class Program
+ {
+ public static void Main(string[] args)
{
- public static void Main(string[] args)
- {
- var host = CreateWebHostBuilder(args).Build();
-
- var env = host.Services.GetRequiredService<IWebHostEnvironment>();
+ var host = CreateWebHostBuilder(args).Build();
- var databaseBackupService = host.Services.GetRequiredService<IDatabaseBackupService>();
- databaseBackupService.BackupNow();
+ var env = host.Services.GetRequiredService<IWebHostEnvironment>();
- if (env.IsProduction())
- {
- using (var scope = host.Services.CreateScope())
- {
- var databaseContext = scope.ServiceProvider.GetRequiredService<DatabaseContext>();
- databaseContext.Database.Migrate();
- }
- }
+ var databaseBackupService = host.Services.GetRequiredService<IDatabaseBackupService>();
+ databaseBackupService.BackupNow();
- host.Run();
+ if (env.IsProduction())
+ {
+ using (var scope = host.Services.CreateScope())
+ {
+ var databaseContext = scope.ServiceProvider.GetRequiredService<DatabaseContext>();
+ databaseContext.Database.Migrate();
}
+ }
- public static IHostBuilder CreateWebHostBuilder(string[] args) =>
- Host.CreateDefaultBuilder(args)
- .ConfigureWebHostDefaults(webBuilder =>
- {
- webBuilder.UseStartup<Startup>();
- });
+ host.Run();
}
+
+ public static IHostBuilder CreateWebHostBuilder(string[] args) =>
+ Host.CreateDefaultBuilder(args)
+ .ConfigureAppConfiguration(config =>
+ {
+ config.AddEnvironmentVariables("Timeline_");
+ })
+ .ConfigureWebHostDefaults(webBuilder =>
+ {
+ webBuilder.UseStartup<Startup>();
+ });
+ }
}
diff --git a/BackEnd/Timeline/Properties/launchSettings.json b/BackEnd/Timeline/Properties/launchSettings.json index a31485ed..db58cd31 100644 --- a/BackEnd/Timeline/Properties/launchSettings.json +++ b/BackEnd/Timeline/Properties/launchSettings.json @@ -5,23 +5,20 @@ "applicationUrl": "http://0.0.0.0:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
- "ASPNETCORE_FRONTEND": "Proxy",
- "ASPNETCORE_WORKDIR": "D:\\timeline-development"
+ "ASPNETCORE_FRONTEND": "Proxy"
}
},
"Dev-Mock": {
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
- "ASPNETCORE_FRONTEND": "Mock",
- "ASPNETCORE_WORKDIR": "D:\\timeline-development"
+ "ASPNETCORE_FRONTEND": "Mock"
}
},
"Staging": {
"commandName": "Project",
"environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Staging",
- "ASPNETCORE_WORKDIR": "D:\\timeline-development"
+ "ASPNETCORE_ENVIRONMENT": "Staging"
}
}
}
|