Skip to content

Commit 64b4db1

Browse files
committed
added configuration
1 parent e6b2251 commit 64b4db1

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"preLaunchTask": "build",
1212
// If you have changed target frameworks, make sure to update the program path.
1313
"program": "${workspaceFolder}/src/StronglyTyped.SampleService/bin/Debug/netcoreapp2.2/StronglyTyped.SampleService.dll",
14-
"args": [],
14+
"args": ["/MySetting:SomeValue=123"],
1515
"cwd": "${workspaceFolder}/src/StronglyTyped.SampleService",
1616
"stopAtEntry": false,
1717
"launchBrowser": {

src/StronglyTyped.SampleService/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public static void Main(string[] args)
1919

2020
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
2121
WebHost.CreateDefaultBuilder(args)
22-
.UseStartup<Startup>();
22+
.UseStartup<Startup>()
23+
.ConfigureAppConfiguration(x => { x.AddCommandLine(args); });
2324
}
2425
}

src/StronglyTyped.SampleService/Startup.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ namespace StronglyTyped.SampleService
1515
{
1616
public class Startup
1717
{
18-
public Startup(IConfiguration configuration)
18+
public Startup(IConfiguration configuration, IHostingEnvironment environment)
1919
{
20-
Configuration = configuration;
20+
Configuration = new ConfigurationBuilder()
21+
.AddJsonFile("appsettings.json")
22+
.AddJsonFile($"appsettings.{environment.EnvironmentName}", optional: true)
23+
.AddEnvironmentVariables()
24+
.AddConfiguration(configuration)
25+
.Build();
2126
}
2227

2328
public IConfiguration Configuration { get; }

0 commit comments

Comments
 (0)