Skip to content

[release/6.0-rc2] Use minimal APIs for F# project templates #36660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Sep 20, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<ItemGroup>
<Compile Include="Models/ErrorViewModel.fs" />
<Compile Include="Controllers/HomeController.fs" />
<Compile Include="Startup.fs" />
<Compile Include="Program.fs" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<ItemGroup>
<Compile Include="WeatherForecast.fs" />
<Compile Include="Controllers/WeatherForecastController.fs" />
<Compile Include="Startup.fs" />
<Compile Include="Program.fs" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,55 @@
namespace Company.WebApplication1

#nowarn "20"

open System
open System.Collections.Generic
open System.IO
open System.Linq
open System.Threading.Tasks
open Microsoft.AspNetCore
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Hosting
#if !NoHttps
open Microsoft.AspNetCore.HttpsPolicy
#endif
open Microsoft.Extensions.Configuration
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Hosting
open Microsoft.Extensions.Logging

module Program =
let exitCode = 0

let CreateHostBuilder args =
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(fun webBuilder ->
webBuilder.UseStartup<Startup>() |> ignore
)

[<EntryPoint>]
let main args =
CreateHostBuilder(args).Build().Run()
let builder = WebApplication.CreateBuilder(args)

builder
.Services
.AddControllersWithViews()
.AddRazorRuntimeCompilation()

builder.Services.AddRazorPages()

let app = builder.Build()

if not (builder.Environment.IsDevelopment()) then
app.UseExceptionHandler("/Home/Error")
#if !NoHttps
app.UseHsts() |> ignore // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.

app.UseHttpsRedirection()
#endif

app.UseStaticFiles()
app.UseRouting()
app.UseAuthorization()

app.MapControllerRoute(name = "default", pattern = "{controller=Home}/{action=Index}/{id?}")

app.MapRazorPages()

app.Run()

exitCode

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
namespace Company.WebApplication1

#nowarn "20"
open System
open System.Collections.Generic
open System.IO
open System.Linq
open System.Threading.Tasks
open Microsoft.AspNetCore
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Hosting
#if !NoHttps
open Microsoft.AspNetCore.HttpsPolicy
#endif
open Microsoft.Extensions.Configuration
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Hosting
open Microsoft.Extensions.Logging

module Program =
let exitCode = 0

let CreateHostBuilder args =
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(fun webBuilder ->
webBuilder.UseStartup<Startup>() |> ignore
)

[<EntryPoint>]
let main args =
CreateHostBuilder(args).Build().Run()

let builder = WebApplication.CreateBuilder(args)

builder.Services.AddControllers()

let app = builder.Build()

#if !NoHttps
app.UseHttpsRedirection()
#endif

app.UseAuthorization()
app.MapControllers()

app.Run()

exitCode

This file was deleted.

2 changes: 0 additions & 2 deletions src/ProjectTemplates/test/template-baselines.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,6 @@
"appsettings.Development.json",
"appsettings.json",
"Program.fs",
"Startup.fs",
"WeatherForecast.fs",
"Controllers/WeatherForecastController.fs",
"Properties/launchSettings.json"
Expand Down Expand Up @@ -1142,7 +1141,6 @@
"appsettings.Development.json",
"appsettings.json",
"Program.fs",
"Startup.fs",
"Controllers/HomeController.fs",
"Models/ErrorViewModel.fs",
"Properties/launchSettings.json",
Expand Down