Skip to content

Commit eb5ce3f

Browse files
migrate to new .net6+ minimal hosting
1 parent fcd0131 commit eb5ce3f

File tree

3 files changed

+39
-83
lines changed

3 files changed

+39
-83
lines changed

ASP.NET Core/ASP.NET Core.csproj

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
57
</PropertyGroup>
8+
69
<Target Name="DebugEnsureNodeEnv" BeforeTargets="BeforeBuild" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
710
<!-- Ensure Node.js is installed -->
811
<Exec Command="node --version" ContinueOnError="true">
@@ -14,18 +17,13 @@
1417
</Target>
1518
<Target Name="RunGulp" BeforeTargets="BeforeBuild" Condition=" '$(Configuration)' == 'Debug' And Exists('$(SpaRoot)node_modules') ">
1619
<Exec WorkingDirectory="$(ProjectDir)" Command="node_modules\.bin\gulp add-resources" ContinueOnError="false">
17-
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
20+
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
1821
</Exec>
1922
</Target>
23+
2024
<ItemGroup>
2125
<PackageReference Include="DevExtreme.AspNet.Data" Version="5.*" />
2226
<PackageReference Include="DevExtreme.AspNet.Core" Version="24.2.*" />
2327
</ItemGroup>
2428

25-
<ProjectExtensions>
26-
<VisualStudio>
27-
<UserProperties TemplateFeatures="NETCORE" />
28-
</VisualStudio>
29-
</ProjectExtensions>
30-
3129
</Project>

ASP.NET Core/Program.cs

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,38 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
5-
using Microsoft.AspNetCore.Hosting;
6-
using Microsoft.Extensions.Configuration;
1+
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.Extensions.DependencyInjection;
73
using Microsoft.Extensions.Hosting;
8-
using Microsoft.Extensions.Logging;
9-
10-
namespace ASP_NET_Core
11-
{
12-
public class Program
13-
{
14-
public static void Main(string[] args)
15-
{
16-
CreateHostBuilder(args).Build().Run();
17-
}
184

19-
public static IHostBuilder CreateHostBuilder(string[] args) =>
20-
Host.CreateDefaultBuilder(args)
21-
.ConfigureWebHostDefaults(webBuilder => {
22-
webBuilder.UseStartup<Startup>();
23-
});
5+
namespace ASP_NET_Core {
6+
public class Program {
7+
public static void Main(string[] args) {
8+
var builder = WebApplication.CreateBuilder(args);
9+
10+
// Add services to the container.
11+
builder.Services
12+
.AddControllersWithViews()
13+
.AddJsonOptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = null);
14+
15+
var app = builder.Build();
16+
17+
// Configure the HTTP request pipeline.
18+
if (app.Environment.IsDevelopment()) {
19+
app.UseDeveloperExceptionPage();
20+
} else {
21+
app.UseExceptionHandler("/Home/Error");
22+
}
23+
24+
app.UseStaticFiles();
25+
26+
app.UseRouting();
27+
28+
app.UseAuthorization();
29+
30+
app.MapControllerRoute(
31+
name: "default",
32+
pattern: "{controller=Home}/{action=Index}/{id?}"
33+
);
34+
35+
app.Run();
36+
}
2437
}
2538
}

ASP.NET Core/Startup.cs

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)