cleanup, add launch settings for console
This commit is contained in:
parent
5cc7965400
commit
29c26ae194
@ -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<IHttpClientFactory>();
|
||||
var httpClient = httpClientFactory.CreateClient();
|
||||
var apiUrl = configuration["ApiUrl"];
|
||||
|
||||
var weatherSet = await httpClient.GetFromJsonAsync<WeatherSet>(apiUrl);
|
||||
|
||||
Console.WriteLine(weatherSet.Current.ConditionName);
|
10
WeatherDashboard.Console/Properties/launchSettings.json
Normal file
10
WeatherDashboard.Console/Properties/launchSettings.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"profiles": {
|
||||
"console": {
|
||||
"commandName": "Project",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -7,6 +7,20 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="appsettings.Development.json" />
|
||||
<None Remove="appsettings.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="appsettings.Development.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
|
||||
@ -17,4 +31,11 @@
|
||||
<ProjectReference Include="..\WeatherDashboard\WeatherDashboard.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Properties\launchSettings.json">
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
3
WeatherDashboard.Console/appsettings.Development.json
Normal file
3
WeatherDashboard.Console/appsettings.Development.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"ApiUrl": "http://localhost:5123/api"
|
||||
}
|
@ -16,13 +16,6 @@
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,6 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Models\**" />
|
||||
<Content Remove="Models\**" />
|
||||
<EmbeddedResource Remove="Models\**" />
|
||||
<None Remove="Models\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<_WebToolingArtifacts Remove="Properties\PublishProfiles\Release.pubxml" />
|
||||
</ItemGroup>
|
||||
|
Loading…
x
Reference in New Issue
Block a user