diff --git a/WeatherDashboard.Console/Program.cs b/WeatherDashboard.Console/Program.cs index f9b23c1..153bd14 100644 --- a/WeatherDashboard.Console/Program.cs +++ b/WeatherDashboard.Console/Program.cs @@ -1,12 +1,18 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using System.Net.Http.Json; +using WeatherDashboard; var builder = Host.CreateDefaultBuilder(args); -builder.ConfigureAppConfiguration(config => +builder.ConfigureAppConfiguration((context, config) => { - config.AddJsonFile("settings.json"); + var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); + + config.AddEnvironmentVariables(); + config.AddJsonFile("appsettings.json"); + config.AddJsonFile($"appsettings.{environment}.json", true); }); builder.ConfigureServices(services => @@ -22,3 +28,6 @@ var httpClientFactory = app.Services.GetService(); var httpClient = httpClientFactory.CreateClient(); var apiUrl = configuration["ApiUrl"]; +var weatherSet = await httpClient.GetFromJsonAsync(apiUrl); + +Console.WriteLine(weatherSet.Current.ConditionName); \ No newline at end of file diff --git a/WeatherDashboard.Console/Properties/launchSettings.json b/WeatherDashboard.Console/Properties/launchSettings.json new file mode 100644 index 0000000..3824b8b --- /dev/null +++ b/WeatherDashboard.Console/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "console": { + "commandName": "Project", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/WeatherDashboard.Console/WeatherDashboard.Console.csproj b/WeatherDashboard.Console/WeatherDashboard.Console.csproj index 41506a9..2279606 100644 --- a/WeatherDashboard.Console/WeatherDashboard.Console.csproj +++ b/WeatherDashboard.Console/WeatherDashboard.Console.csproj @@ -7,6 +7,20 @@ enable + + + + + + + + PreserveNewest + + + PreserveNewest + + + @@ -17,4 +31,11 @@ + + + true + Never + + + diff --git a/WeatherDashboard.Console/appsettings.Development.json b/WeatherDashboard.Console/appsettings.Development.json new file mode 100644 index 0000000..b6f603e --- /dev/null +++ b/WeatherDashboard.Console/appsettings.Development.json @@ -0,0 +1,3 @@ +{ + "ApiUrl": "http://localhost:5123/api" +} \ No newline at end of file diff --git a/WeatherDashboard.Console/settings.json b/WeatherDashboard.Console/appsettings.json similarity index 100% rename from WeatherDashboard.Console/settings.json rename to WeatherDashboard.Console/appsettings.json diff --git a/WeatherDashboard.Console/settings.Development.json b/WeatherDashboard.Console/settings.Development.json deleted file mode 100644 index e69de29..0000000 diff --git a/WeatherDashboard.Web/Properties/launchSettings.json b/WeatherDashboard.Web/Properties/launchSettings.json index 232963c..144d802 100644 --- a/WeatherDashboard.Web/Properties/launchSettings.json +++ b/WeatherDashboard.Web/Properties/launchSettings.json @@ -16,13 +16,6 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } } } } diff --git a/WeatherDashboard.Web/WeatherDashboard.Web.csproj b/WeatherDashboard.Web/WeatherDashboard.Web.csproj index 4f562f7..e65e64c 100644 --- a/WeatherDashboard.Web/WeatherDashboard.Web.csproj +++ b/WeatherDashboard.Web/WeatherDashboard.Web.csproj @@ -6,13 +6,6 @@ enable - - - - - - - <_WebToolingArtifacts Remove="Properties\PublishProfiles\Release.pubxml" />