Skip to content

Commit

Permalink
upgrade from dot net 3.1 to 7 and use minimal hosting model
Browse files Browse the repository at this point in the history
  • Loading branch information
szetok committed Nov 3, 2023
1 parent de0ed3b commit 2c67886
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.1/sm-coding-challenge.dll",
"program": "${workspaceFolder}/bin/Debug/net7.0/sm-coding-challenge.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
Expand Down
38 changes: 23 additions & 15 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using sm_coding_challenge.Services.DataProvider;

namespace sm_coding_challenge
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllersWithViews();
builder.Services.AddTransient<IDataProvider, DataProviderImpl>();

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
var app = builder.Build();
IWebHostEnvironment env = app.Environment;
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseStaticFiles();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();
55 changes: 0 additions & 55 deletions Startup.cs

This file was deleted.

6 changes: 3 additions & 3 deletions sm-coding-challenge.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

</Project>

0 comments on commit 2c67886

Please sign in to comment.