From 5b34474502104e172d9b5c28a5149956dbf4de5f Mon Sep 17 00:00:00 2001 From: Phillip Carter Date: Thu, 4 Jan 2018 10:56:54 -0800 Subject: [PATCH] Update F# templates (#190) --- .../EmptyWeb-FSharp.fsproj.in | 3 ++ .../StarterWeb-FSharp.fsproj.in | 1 + .../WebApi-FSharp.fsproj.in | 1 + .../.template.config/dotnetcli.host.json | 12 +++++++- .../.template.config/template.json | 12 ++++++++ .../Properties/launchSettings.json | 28 +++++++++++++++++++ .../content/EmptyWeb-FSharp/Startup.fs | 11 ++++---- .../.template.config/dotnetcli.host.json | 2 +- .../.template.config/template.json | 24 ++++++++++++---- .../content/StarterWeb-FSharp/Startup.fs | 8 ++---- .../.template.config/template.json | 6 ++++ .../content/WebApi-FSharp/Startup.fs | 12 ++++---- 12 files changed, 97 insertions(+), 23 deletions(-) create mode 100644 src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/Properties/launchSettings.json diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/EmptyWeb-FSharp.fsproj.in b/src/Microsoft.DotNet.Web.ProjectTemplates/EmptyWeb-FSharp.fsproj.in index 82453e4d8e..17499e4ddc 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/EmptyWeb-FSharp.fsproj.in +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/EmptyWeb-FSharp.fsproj.in @@ -15,6 +15,9 @@ + + + diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/StarterWeb-FSharp.fsproj.in b/src/Microsoft.DotNet.Web.ProjectTemplates/StarterWeb-FSharp.fsproj.in index e2ff0d0658..400372f406 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/StarterWeb-FSharp.fsproj.in +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/StarterWeb-FSharp.fsproj.in @@ -23,6 +23,7 @@ + diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/WebApi-FSharp.fsproj.in b/src/Microsoft.DotNet.Web.ProjectTemplates/WebApi-FSharp.fsproj.in index 63fdbba6b8..5b328d9730 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/WebApi-FSharp.fsproj.in +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/WebApi-FSharp.fsproj.in @@ -19,6 +19,7 @@ + diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/.template.config/dotnetcli.host.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/.template.config/dotnetcli.host.json index 04017b2a43..c5d4c2f7a4 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/.template.config/dotnetcli.host.json +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/.template.config/dotnetcli.host.json @@ -13,6 +13,16 @@ "longName": "no-restore", "shortName": "" }, + "HttpPort": { + "isHidden": true + }, + "HttpsPort": { + "isHidden": true + }, + "ExcludeLaunchSettings": { + "longName": "exclude-launch-settings", + "shortName": "" + }, "RuntimeFrameworkVersion": { "longName": "runtime-framework-version", "shortName": "fv", @@ -22,4 +32,4 @@ "usageExamples": [ "" ] -} +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/.template.config/template.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/.template.config/template.json index 8ec0e1ad1a..e4f8150508 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/.template.config/template.json +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/.template.config/template.json @@ -26,6 +26,12 @@ "exclude": [ "app.config" ] + }, + { + "condition": "(ExcludeLaunchSettings)", + "exclude": [ + "Properties/launchSettings.json" + ] } ] } @@ -37,6 +43,12 @@ "datatype": "string", "defaultValue": "2.1.0-preview2-25624-02" }, + "ExcludeLaunchSettings": { + "type": "parameter", + "datatype": "bool", + "defaultValue": "false", + "description": "Whether to exclude launchSettings.json from the generated template." + }, "TargetFrameworkOverride": { "type": "parameter", "description": "Overrides the target framework", diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/Properties/launchSettings.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/Properties/launchSettings.json new file mode 100644 index 0000000000..24f900eae9 --- /dev/null +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/Properties/launchSettings.json @@ -0,0 +1,28 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:8080", + "sslPort": 44300 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_HTTPS_PORT": "44300" + } + }, + "Company.WebApplication1": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_URLS": "https://localhost:44300;http://localhost:8080" + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/Startup.fs b/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/Startup.fs index 525a7a2a05..142130c1f0 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/Startup.fs +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-FSharp/Startup.fs @@ -1,6 +1,5 @@ namespace Company.WebApplication1 -open System open Microsoft.AspNetCore.Builder open Microsoft.AspNetCore.Hosting open Microsoft.AspNetCore.Http @@ -8,12 +7,14 @@ open Microsoft.Extensions.DependencyInjection type Startup() = + // This method gets called by the runtime. Use this method to add services to the container. + // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 member this.ConfigureServices(services: IServiceCollection) = () + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. member this.Configure(app: IApplicationBuilder, env: IHostingEnvironment) = - if env.IsDevelopment() then app.UseDeveloperExceptionPage() |> ignore + if env.IsDevelopment() then + app.UseDeveloperExceptionPage() |> ignore - app.Run(fun context -> context.Response.WriteAsync("Hello World!")) - - () \ No newline at end of file + app.Run(fun context -> context.Response.WriteAsync("Hello World!")) |> ignore \ No newline at end of file diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/.template.config/dotnetcli.host.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/.template.config/dotnetcli.host.json index 098d0fa37c..382744612d 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/.template.config/dotnetcli.host.json +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/.template.config/dotnetcli.host.json @@ -1,5 +1,5 @@ { -"$schema": "http://json.schemastore.org/dotnetcli.host", + "$schema": "http://json.schemastore.org/dotnetcli.host", "symbolInfo": { "HttpPort": { "isHidden": true diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/.template.config/template.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/.template.config/template.json index 7b07f45d54..4e7c28308b 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/.template.config/template.json +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/.template.config/template.json @@ -27,17 +27,35 @@ "exclude": [ "app.config" ] + }, + { + "condition": "(ExcludeLaunchSettings)", + "exclude": [ + "Properties/launchSettings.json" + ] } ] } ], "symbols": { + "RuntimeFrameworkVersion": { + "type": "parameter", + "replaces": "2.1.0-preview2-25624-02", + "datatype": "string", + "defaultValue": "2.1.0-preview2-25624-02" + }, "ExcludeLaunchSettings": { "type": "parameter", "datatype": "bool", "defaultValue": "false", "description": "Whether to exclude launchSettings.json from the generated template." }, + "UseBrowserLink": { + "type": "parameter", + "datatype": "bool", + "defaultValue": "false", + "description": "Whether or not to include BrowserLink in the project" + }, "HttpPort": { "type": "parameter", "datatype": "integer", @@ -78,12 +96,6 @@ }, "replaces": "44300" }, - "RuntimeFrameworkVersion": { - "type": "parameter", - "replaces": "2.1.0-preview2-25624-02", - "datatype": "string", - "defaultValue": "2.1.0-preview2-25624-02" - }, "TargetFrameworkOverride": { "type": "parameter", "description": "Overrides the target framework", diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/Startup.fs b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/Startup.fs index 0ff184dc1c..a00f0e005e 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/Startup.fs +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/Startup.fs @@ -1,15 +1,11 @@ namespace Company.WebApplication1 -open System -open System.Collections.Generic -open System.Linq -open System.Threading.Tasks open Microsoft.AspNetCore.Builder open Microsoft.AspNetCore.Hosting +open Microsoft.AspNetCore.HttpsPolicy open Microsoft.Extensions.Configuration open Microsoft.Extensions.DependencyInjection - type Startup private () = new (configuration: IConfiguration) as this = Startup() then @@ -27,7 +23,9 @@ type Startup private () = app.UseDeveloperExceptionPage() |> ignore else app.UseExceptionHandler("/Home/Error") |> ignore + app.UseHsts() |> ignore + app.UseHttpsRedirection() |> ignore app.UseStaticFiles() |> ignore app.UseMvc(fun routes -> diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/.template.config/template.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/.template.config/template.json index fc88b2b8de..7f4e679d08 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/.template.config/template.json +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/.template.config/template.json @@ -26,6 +26,12 @@ "exclude": [ "app.config" ] + }, + { + "condition": "(ExcludeLaunchSettings)", + "exclude": [ + "Properties/launchSettings.json" + ] } ] } diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs index 075193a4aa..bc17f8cefa 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs @@ -1,15 +1,11 @@ namespace Company.WebApplication1 -open System -open System.Collections.Generic -open System.Linq -open System.Threading.Tasks open Microsoft.AspNetCore.Builder open Microsoft.AspNetCore.Hosting +open Microsoft.AspNetCore.HttpsPolicy open Microsoft.Extensions.Configuration open Microsoft.Extensions.DependencyInjection - type Startup private () = new (configuration: IConfiguration) as this = Startup() then @@ -22,6 +18,12 @@ type Startup private () = // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. member this.Configure(app: IApplicationBuilder, env: IHostingEnvironment) = + if (env.IsDevelopment()) then + app.UseDeveloperExceptionPage() |> ignore + else + app.UseHsts() |> ignore + + app.UseHttpsRedirection() |> ignore app.UseMvc() |> ignore member val Configuration : IConfiguration = null with get, set \ No newline at end of file