From 4d2e642b94ad6c2e152e09005c33bac7543bcf04 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Thu, 16 Nov 2017 14:27:12 -0800 Subject: [PATCH] Add launchSettings.json by default to our templates * Adds launchSettings.json to all of our templates. * Provides an alternative flag to exclude it. * Adds HTTPS support in launchSettings.json. * Re-adds HTTPS redirect and HSTS middleware for C# templates. * Improves some infrastructure aspects: * Prefix all our test projects with AspNet.Template to allow easy killing of orphaned processes. * Setup an HTTPS certificate automatically for use with tests in the same way our tooling does it on customers machines. * Switch from OS selected ports to randomly selected ports. This is required as we need to know the port to use for HTTPS. * Allow disabling browser automation through an environment variable. * Setup Firefox to allow untrusted certificates when using Selenium. * Allow running Selenium tests on firefox by setting an environment variable. --- .gitignore | 1 - build/dependencies.props | 6 +- .../Aurelia-CSharp.csproj.in | 1 + .../Knockout-CSharp.csproj.in | 1 + .../Microsoft.AspNetCore.SpaTemplates.csproj | 1 + .../Vue-CSharp.csproj.in | 1 + .../.template.config/dotnetcli.host.json | 10 +++ .../.template.config/template.json | 54 ++++++++++++++++ .../.template.config/vs-2017.3.host.json | 7 ++ .../Properties/launchSettings.json | 29 +++++++++ .../content/Aurelia-CSharp/Startup.cs | 3 + .../.template.config/dotnetcli.host.json | 10 +++ .../.template.config/template.json | 54 ++++++++++++++++ .../.template.config/vs-2017.3.host.json | 7 ++ .../Properties/launchSettings.json | 29 +++++++++ .../content/Knockout-CSharp/Startup.cs | 3 + .../.template.config/dotnetcli.host.json | 10 +++ .../Vue-CSharp/.template.config/template.json | 54 ++++++++++++++++ .../.template.config/vs-2017.3.host.json | 7 ++ .../Vue-CSharp/Properties/launchSettings.json | 29 +++++++++ .../content/Vue-CSharp/Startup.cs | 3 + ...crosoft.DotNet.Web.ProjectTemplates.csproj | 1 + .../RazorPagesWeb-CSharp.csproj.in | 1 + .../StarterWeb-CSharp.csproj.in | 1 + .../WebApi-CSharp.csproj.in | 1 + .../.template.config/dotnetcli.host.json | 8 +-- .../.template.config/template.json | 40 ++++++------ .../.template.config/vs-2017.3.host.json | 10 +-- .../Properties/launchSettings.json | 29 +++++++++ .../.template.config/dotnetcli.host.json | 13 ++-- .../.template.config/template.json | 64 +++++++------------ .../.template.config/vs-2017.3.host.json | 10 +-- .../Properties/launchSettings.json | 29 +++++++++ .../content/RazorPagesWeb-CSharp/Startup.cs | 3 + .../.template.config/dotnetcli.host.json | 13 ++-- .../.template.config/template.json | 64 +++++++------------ .../.template.config/vs-2017.3.host.json | 10 +-- .../Properties/launchSettings.json | 29 +++++++++ .../content/StarterWeb-CSharp/Startup.cs | 3 + .../.template.config/dotnetcli.host.json | 10 +++ .../.template.config/template.json | 48 +++++++++++++- .../Properties/launchSettings.json | 29 +++++++++ .../.template.config/dotnetcli.host.json | 13 ++-- .../.template.config/template.json | 64 +++++++------------ .../.template.config/vs-2017.3.host.json | 10 +-- .../Properties/launchSettings.json | 29 +++++++++ .../content/WebApi-CSharp/Startup.cs | 6 ++ .../.template.config/dotnetcli.host.json | 10 +++ .../.template.config/template.json | 46 +++++++++++++ .../Properties/launchSettings.json | 29 +++++++++ .../Angular-CSharp.csproj.in | 1 + ...oft.DotNet.Web.Spa.ProjectTemplates.csproj | 1 + .../React-CSharp.csproj.in | 1 + .../ReactRedux-CSharp.csproj.in | 1 + .../.template.config/dotnetcli.host.json | 10 +++ .../.template.config/template.json | 56 +++++++++++++++- .../.template.config/vs-2017.3.host.json | 7 ++ .../Properties/launchSettings.json | 29 +++++++++ .../content/Angular-CSharp/Startup.cs | 2 + .../.template.config/dotnetcli.host.json | 10 +++ .../.template.config/template.json | 54 ++++++++++++++++ .../.template.config/vs-2017.3.host.json | 7 ++ .../Properties/launchSettings.json | 29 +++++++++ .../content/React-CSharp/Startup.cs | 3 + .../.template.config/dotnetcli.host.json | 10 +++ .../.template.config/template.json | 54 ++++++++++++++++ .../.template.config/vs-2017.3.host.json | 7 ++ .../Properties/launchSettings.json | 29 +++++++++ .../content/ReactRedux-CSharp/Startup.cs | 3 + test/Templates.Test/Helpers/AspNetProcess.cs | 21 +++++- .../Helpers/TemplateTestBase.cs | 4 +- .../Helpers/WebDriverFactory.cs | 33 +++++++--- test/Templates.Test/MvcTemplateTest.cs | 2 +- .../SpaTemplateTest/SpaTemplateTestBase.cs | 2 +- test/Templates.Test/Templates.Test.csproj | 2 + 75 files changed, 1099 insertions(+), 222 deletions(-) create mode 100644 src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/Properties/launchSettings.json create mode 100644 src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/Properties/launchSettings.json create mode 100644 src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/Properties/launchSettings.json create mode 100644 src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/Properties/launchSettings.json create mode 100644 src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Properties/launchSettings.json create mode 100644 src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Properties/launchSettings.json create mode 100644 src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/Properties/launchSettings.json create mode 100644 src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/Properties/launchSettings.json create mode 100644 src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Properties/launchSettings.json create mode 100644 src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/Properties/launchSettings.json create mode 100644 src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/Properties/launchSettings.json create mode 100644 src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/Properties/launchSettings.json diff --git a/.gitignore b/.gitignore index ac5acff5f6..490b20e56f 100644 --- a/.gitignore +++ b/.gitignore @@ -32,7 +32,6 @@ nuget.exe *.sln.ide node_modules **/[Cc]ompiler/[Rr]esources/**/*.js -*launchSettings.json .build/ .testPublish/ .vscode diff --git a/build/dependencies.props b/build/dependencies.props index 8e20a33a6b..19e9f5973c 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -8,7 +8,9 @@ 2.1.0-preview1-27644 2.1.0-preview1-27644 2.1.0-preview1-27644 + 2.1.0-preview1-27644 2.1.0-preview1-27644 + 2.1.0-preview1-27644 2.1.0-preview1-27644 2.1.0-preview1-27644 2.1.0-preview1-27644 @@ -35,9 +37,9 @@ 2.1.0-preview1-27644 2.0.0 0.19.0 - 3.6.0 + 3.7.0 16.16299.0 - 3.6.0 + 3.7.0 4.4.0 0.7.0 2.3.0 diff --git a/src/Microsoft.AspNetCore.SpaTemplates/Aurelia-CSharp.csproj.in b/src/Microsoft.AspNetCore.SpaTemplates/Aurelia-CSharp.csproj.in index f9921057ee..944bf6dba6 100644 --- a/src/Microsoft.AspNetCore.SpaTemplates/Aurelia-CSharp.csproj.in +++ b/src/Microsoft.AspNetCore.SpaTemplates/Aurelia-CSharp.csproj.in @@ -13,6 +13,7 @@ + diff --git a/src/Microsoft.AspNetCore.SpaTemplates/Knockout-CSharp.csproj.in b/src/Microsoft.AspNetCore.SpaTemplates/Knockout-CSharp.csproj.in index f9921057ee..944bf6dba6 100644 --- a/src/Microsoft.AspNetCore.SpaTemplates/Knockout-CSharp.csproj.in +++ b/src/Microsoft.AspNetCore.SpaTemplates/Knockout-CSharp.csproj.in @@ -13,6 +13,7 @@ + diff --git a/src/Microsoft.AspNetCore.SpaTemplates/Microsoft.AspNetCore.SpaTemplates.csproj b/src/Microsoft.AspNetCore.SpaTemplates/Microsoft.AspNetCore.SpaTemplates.csproj index 5a5bdc3b3a..f1f2f63094 100644 --- a/src/Microsoft.AspNetCore.SpaTemplates/Microsoft.AspNetCore.SpaTemplates.csproj +++ b/src/Microsoft.AspNetCore.SpaTemplates/Microsoft.AspNetCore.SpaTemplates.csproj @@ -13,6 +13,7 @@ MicrosoftAspNetCoreAllPackageVersion=$(MicrosoftAspNetCoreAllPackageVersion); MicrosoftAspNetCoreMvcPackageVersion=$(MicrosoftAspNetCoreMvcPackageVersion); + MicrosoftAspNetCoreHttpsPolicyPackageVersion=$(MicrosoftAspNetCoreHttpsPolicyPackageVersion); MicrosoftAspNetCorePackageVersion=$(MicrosoftAspNetCorePackageVersion); MicrosoftAspNetCoreSpaServicesPackageVersion=$(MicrosoftAspNetCoreSpaServicesPackageVersion); MicrosoftAspNetCoreStaticFilesPackageVersion=$(MicrosoftAspNetCoreStaticFilesPackageVersion); diff --git a/src/Microsoft.AspNetCore.SpaTemplates/Vue-CSharp.csproj.in b/src/Microsoft.AspNetCore.SpaTemplates/Vue-CSharp.csproj.in index f9921057ee..944bf6dba6 100644 --- a/src/Microsoft.AspNetCore.SpaTemplates/Vue-CSharp.csproj.in +++ b/src/Microsoft.AspNetCore.SpaTemplates/Vue-CSharp.csproj.in @@ -13,6 +13,7 @@ + diff --git a/src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/.template.config/dotnetcli.host.json b/src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/.template.config/dotnetcli.host.json index c15c6681aa..d27ce640cb 100644 --- a/src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/.template.config/dotnetcli.host.json +++ b/src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/.template.config/dotnetcli.host.json @@ -12,6 +12,16 @@ "skipRestore": { "longName": "no-restore", "shortName": "" + }, + "HttpPort": { + "isHidden": true + }, + "HttpsPort": { + "isHidden": true + }, + "ExcludeLaunchSettings": { + "longName": "exclude-launch-settings", + "shortName": "" } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/.template.config/template.json b/src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/.template.config/template.json index d6f128e26a..3b175f8ab2 100644 --- a/src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/.template.config/template.json +++ b/src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/.template.config/template.json @@ -22,10 +22,64 @@ "target": "./", "exclude": [ ".template.config/**" + ], + "modifiers": [ + { + "condition": "(ExcludeLaunchSettings)", + "exclude": [ + "Properties/launchSettings.json" + ] + } ] } ], "symbols": { + "ExcludeLaunchSettings": { + "type": "parameter", + "datatype": "bool", + "defaultValue": "false", + "description": "Whether to exclude launchSettings.json from the generated template." + }, + "HttpPort": { + "type": "parameter", + "datatype": "integer", + "description": "Port number to use for the HTTP endpoint in launchSettings.json." + }, + "HttpPortGenerated": { + "type": "generated", + "generator": "port" + }, + "HttpPortReplacer": { + "type": "generated", + "generator": "coalesce", + "parameters": { + "sourceVariableName": "HttpPort", + "fallbackVariableName": "HttpPortGenerated" + }, + "replaces": "8080" + }, + "HttpsPort": { + "type": "parameter", + "datatype": "integer", + "description": "Port number to use for the HTTPS endpoint in launchSettings.json." + }, + "HttpsPortGenerated": { + "type": "generated", + "generator": "port", + "parameters": { + "low": 44300, + "high": 44399 + } + }, + "HttpsPortReplacer": { + "type": "generated", + "generator": "coalesce", + "parameters": { + "sourceVariableName": "HttpsPort", + "fallbackVariableName": "HttpsPortGenerated" + }, + "replaces": "44300" + }, "TargetFrameworkOverride": { "type": "parameter", "description": "Overrides the target framework", diff --git a/src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/.template.config/vs-2017.3.host.json b/src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/.template.config/vs-2017.3.host.json index 18e8697a7b..e0abb41fc1 100644 --- a/src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/.template.config/vs-2017.3.host.json +++ b/src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/.template.config/vs-2017.3.host.json @@ -16,5 +16,12 @@ "uiFilters": [ "oneaspnet" ], + "ports": [ + { + "name": "HttpsPort", + "useHttps": true + } + ], + "excludeLaunchSettings": false, "minFullFrameworkVersion": "4.6.1" } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/Properties/launchSettings.json b/src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/Properties/launchSettings.json new file mode 100644 index 0000000000..0dd1d3c232 --- /dev/null +++ b/src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "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_HTTPS_PORT": "44300", + "ASPNETCORE_URLS": "https://localhost:44300;http://localhost:8080" + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/Startup.cs b/src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/Startup.cs index 4a96590eb5..fceee2f8f9 100644 --- a/src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/Startup.cs +++ b/src/Microsoft.AspNetCore.SpaTemplates/content/Aurelia-CSharp/Startup.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.AspNetCore.SpaServices.Webpack; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -39,8 +40,10 @@ namespace AureliaSpa else { app.UseExceptionHandler("/Home/Error"); + app.UseHsts(); } + app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseMvc(routes => diff --git a/src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/.template.config/dotnetcli.host.json b/src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/.template.config/dotnetcli.host.json index c15c6681aa..d27ce640cb 100644 --- a/src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/.template.config/dotnetcli.host.json +++ b/src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/.template.config/dotnetcli.host.json @@ -12,6 +12,16 @@ "skipRestore": { "longName": "no-restore", "shortName": "" + }, + "HttpPort": { + "isHidden": true + }, + "HttpsPort": { + "isHidden": true + }, + "ExcludeLaunchSettings": { + "longName": "exclude-launch-settings", + "shortName": "" } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/.template.config/template.json b/src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/.template.config/template.json index ef80d53bf9..05597293a1 100644 --- a/src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/.template.config/template.json +++ b/src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/.template.config/template.json @@ -22,10 +22,64 @@ "target": "./", "exclude": [ ".template.config/**" + ], + "modifiers": [ + { + "condition": "(ExcludeLaunchSettings)", + "exclude": [ + "Properties/launchSettings.json" + ] + } ] } ], "symbols": { + "ExcludeLaunchSettings": { + "type": "parameter", + "datatype": "bool", + "defaultValue": "false", + "description": "Whether to exclude launchSettings.json from the generated template." + }, + "HttpPort": { + "type": "parameter", + "datatype": "integer", + "description": "Port number to use for the HTTP endpoint in launchSettings.json." + }, + "HttpPortGenerated": { + "type": "generated", + "generator": "port" + }, + "HttpPortReplacer": { + "type": "generated", + "generator": "coalesce", + "parameters": { + "sourceVariableName": "HttpPort", + "fallbackVariableName": "HttpPortGenerated" + }, + "replaces": "8080" + }, + "HttpsPort": { + "type": "parameter", + "datatype": "integer", + "description": "Port number to use for the HTTPS endpoint in launchSettings.json." + }, + "HttpsPortGenerated": { + "type": "generated", + "generator": "port", + "parameters": { + "low": 44300, + "high": 44399 + } + }, + "HttpsPortReplacer": { + "type": "generated", + "generator": "coalesce", + "parameters": { + "sourceVariableName": "HttpsPort", + "fallbackVariableName": "HttpsPortGenerated" + }, + "replaces": "44300" + }, "TargetFrameworkOverride": { "type": "parameter", "description": "Overrides the target framework", diff --git a/src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/.template.config/vs-2017.3.host.json b/src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/.template.config/vs-2017.3.host.json index 7ce1189fd6..930c8852c5 100644 --- a/src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/.template.config/vs-2017.3.host.json +++ b/src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/.template.config/vs-2017.3.host.json @@ -16,5 +16,12 @@ "uiFilters": [ "oneaspnet" ], + "ports": [ + { + "name": "HttpsPort", + "useHttps": true + } + ], + "excludeLaunchSettings": false, "minFullFrameworkVersion": "4.6.1" } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/Properties/launchSettings.json b/src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/Properties/launchSettings.json new file mode 100644 index 0000000000..0dd1d3c232 --- /dev/null +++ b/src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "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_HTTPS_PORT": "44300", + "ASPNETCORE_URLS": "https://localhost:44300;http://localhost:8080" + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/Startup.cs b/src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/Startup.cs index fc7290b482..f6d51ad03e 100644 --- a/src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/Startup.cs +++ b/src/Microsoft.AspNetCore.SpaTemplates/content/Knockout-CSharp/Startup.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.AspNetCore.SpaServices.Webpack; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -39,8 +40,10 @@ namespace KnockoutSpa else { app.UseExceptionHandler("/Home/Error"); + app.UseHsts(); } + app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseMvc(routes => diff --git a/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/.template.config/dotnetcli.host.json b/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/.template.config/dotnetcli.host.json index c15c6681aa..d27ce640cb 100644 --- a/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/.template.config/dotnetcli.host.json +++ b/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/.template.config/dotnetcli.host.json @@ -12,6 +12,16 @@ "skipRestore": { "longName": "no-restore", "shortName": "" + }, + "HttpPort": { + "isHidden": true + }, + "HttpsPort": { + "isHidden": true + }, + "ExcludeLaunchSettings": { + "longName": "exclude-launch-settings", + "shortName": "" } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/.template.config/template.json b/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/.template.config/template.json index 727ae230f8..2225ee70d6 100644 --- a/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/.template.config/template.json +++ b/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/.template.config/template.json @@ -22,10 +22,64 @@ "target": "./", "exclude": [ ".template.config/**" + ], + "modifiers": [ + { + "condition": "(ExcludeLaunchSettings)", + "exclude": [ + "Properties/launchSettings.json" + ] + } ] } ], "symbols": { + "ExcludeLaunchSettings": { + "type": "parameter", + "datatype": "bool", + "defaultValue": "false", + "description": "Whether to exclude launchSettings.json from the generated template." + }, + "HttpPort": { + "type": "parameter", + "datatype": "integer", + "description": "Port number to use for the HTTP endpoint in launchSettings.json." + }, + "HttpPortGenerated": { + "type": "generated", + "generator": "port" + }, + "HttpPortReplacer": { + "type": "generated", + "generator": "coalesce", + "parameters": { + "sourceVariableName": "HttpPort", + "fallbackVariableName": "HttpPortGenerated" + }, + "replaces": "8080" + }, + "HttpsPort": { + "type": "parameter", + "datatype": "integer", + "description": "Port number to use for the HTTPS endpoint in launchSettings.json." + }, + "HttpsPortGenerated": { + "type": "generated", + "generator": "port", + "parameters": { + "low": 44300, + "high": 44399 + } + }, + "HttpsPortReplacer": { + "type": "generated", + "generator": "coalesce", + "parameters": { + "sourceVariableName": "HttpsPort", + "fallbackVariableName": "HttpsPortGenerated" + }, + "replaces": "44300" + }, "TargetFrameworkOverride": { "type": "parameter", "description": "Overrides the target framework", diff --git a/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/.template.config/vs-2017.3.host.json b/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/.template.config/vs-2017.3.host.json index 9b9b6a5f05..f2780cf753 100644 --- a/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/.template.config/vs-2017.3.host.json +++ b/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/.template.config/vs-2017.3.host.json @@ -16,5 +16,12 @@ "uiFilters": [ "oneaspnet" ], + "ports": [ + { + "name": "HttpsPort", + "useHttps": true + } + ], + "excludeLaunchSettings": false, "minFullFrameworkVersion": "4.6.1" } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/Properties/launchSettings.json b/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/Properties/launchSettings.json new file mode 100644 index 0000000000..0dd1d3c232 --- /dev/null +++ b/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "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_HTTPS_PORT": "44300", + "ASPNETCORE_URLS": "https://localhost:44300;http://localhost:8080" + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/Startup.cs b/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/Startup.cs index c79526fd5d..630bbfc38b 100644 --- a/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/Startup.cs +++ b/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/Startup.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.AspNetCore.SpaServices.Webpack; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -39,8 +40,10 @@ namespace VueSpa else { app.UseExceptionHandler("/Home/Error"); + app.UseHsts(); } + app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseMvc(routes => diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj b/src/Microsoft.DotNet.Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj index ad29b5d755..43260fc5bc 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj @@ -18,6 +18,7 @@ MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion=$(MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion); MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion=$(MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion); MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion=$(MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion); + MicrosoftAspNetCoreHttpsPolicyPackageVersion=$(MicrosoftAspNetCoreHttpsPolicyPackageVersion); MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion=$(MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion); MicrosoftAspNetCoreMvcPackageVersion=$(MicrosoftAspNetCoreMvcPackageVersion); MicrosoftAspNetCoreMvcRazorViewCompilationPackageVersion=$(MicrosoftAspNetCoreMvcRazorViewCompilationPackageVersion); diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/RazorPagesWeb-CSharp.csproj.in b/src/Microsoft.DotNet.Web.ProjectTemplates/RazorPagesWeb-CSharp.csproj.in index 4ced50cdde..91412ff6c5 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/RazorPagesWeb-CSharp.csproj.in +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/RazorPagesWeb-CSharp.csproj.in @@ -25,6 +25,7 @@ + diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/StarterWeb-CSharp.csproj.in b/src/Microsoft.DotNet.Web.ProjectTemplates/StarterWeb-CSharp.csproj.in index 9ac27aea56..80a347ece1 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/StarterWeb-CSharp.csproj.in +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/StarterWeb-CSharp.csproj.in @@ -26,6 +26,7 @@ + diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/WebApi-CSharp.csproj.in b/src/Microsoft.DotNet.Web.ProjectTemplates/WebApi-CSharp.csproj.in index 7d52f5e1d5..55519673c1 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/WebApi-CSharp.csproj.in +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/WebApi-CSharp.csproj.in @@ -21,6 +21,7 @@ + diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/.template.config/dotnetcli.host.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/.template.config/dotnetcli.host.json index 8381117bc2..e1764c72e9 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/.template.config/dotnetcli.host.json +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/.template.config/dotnetcli.host.json @@ -13,14 +13,14 @@ "longName": "no-restore", "shortName": "" }, - "KestrelPort": { + "HttpPort": { "isHidden": true }, - "IISExpressPort": { + "HttpsPort": { "isHidden": true }, - "IncludeLaunchSettings": { - "longName": "use-launch-settings", + "ExcludeLaunchSettings": { + "longName": "exclude-launch-settings", "shortName": "" }, "RuntimeFrameworkVersion": { diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/.template.config/template.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/.template.config/template.json index 922871b524..8354091b9d 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/.template.config/template.json +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/.template.config/template.json @@ -26,7 +26,7 @@ { "modifiers": [ { - "condition": "(!IncludeLaunchSettings)", + "condition": "(ExcludeLaunchSettings)", "exclude": [ "Properties/launchSettings.json" ] @@ -41,47 +41,51 @@ "datatype": "string", "defaultValue": "2.1.0-preview2-25624-02" }, - "IncludeLaunchSettings": { + "ExcludeLaunchSettings": { "type": "parameter", "datatype": "bool", "defaultValue": "false", - "description": "Whether to include launchSettings.json in the generated template." + "description": "Whether to exclude launchSettings.json from the generated template." }, - "KestrelPort": { + "HttpPort": { "type": "parameter", "datatype": "integer", - "description": "Port number to use to configure Kestrel in launchSettings.json." + "description": "Port number to use for the HTTP endpoint in launchSettings.json." }, - "KestrelPortGenerated": { + "HttpPortGenerated": { "type": "generated", "generator": "port" }, - "KestrelPortReplacer": { + "HttpPortReplacer": { "type": "generated", "generator": "coalesce", "parameters": { - "sourceVariableName": "KestrelPort", - "fallbackVariableName": "KestrelPortGenerated" + "sourceVariableName": "HttpPort", + "fallbackVariableName": "HttpPortGenerated" }, - "replaces": "5000" + "replaces": "8080" }, - "IISExpressPort": { + "HttpsPort": { "type": "parameter", "datatype": "integer", - "description": "Port number to use to configure IIS Express in launchSettings.json." + "description": "Port number to use for the HTTPS endpoint in launchSettings.json." }, - "IISExpressPortGenerated": { + "HttpsPortGenerated": { "type": "generated", - "generator": "port" + "generator": "port", + "parameters": { + "low": 44300, + "high": 44399 + } }, - "IISExpressPortReplacer": { + "HttpsPortReplacer": { "type": "generated", "generator": "coalesce", "parameters": { - "sourceVariableName": "IISExpressPort", - "fallbackVariableName": "IISExpressPortGenerated" + "sourceVariableName": "HttpsPort", + "fallbackVariableName": "HttpsPortGenerated" }, - "replaces": "55556" + "replaces": "44300" }, "TargetFrameworkOverride": { "type": "parameter", diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/.template.config/vs-2017.3.host.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/.template.config/vs-2017.3.host.json index 3d9b518a3e..479a682250 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/.template.config/vs-2017.3.host.json +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/.template.config/vs-2017.3.host.json @@ -18,14 +18,10 @@ "legacyTemplateIdentity": "Microsoft.NetCore.CSharp.EmptyWeb", "ports": [ { - "name": "IISExpressPort", - "useHttps": false - }, - { - "name": "KestrelPort", - "useHttps": false + "name": "HttpsPort", + "useHttps": true } ], - "includeLaunchSettings": true, + "excludeLaunchSettings": false, "minFullFrameworkVersion": "4.6.1" } diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/Properties/launchSettings.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/Properties/launchSettings.json new file mode 100644 index 0000000000..0dd1d3c232 --- /dev/null +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/EmptyWeb-CSharp/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "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_HTTPS_PORT": "44300", + "ASPNETCORE_URLS": "https://localhost:44300;http://localhost:8080" + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/.template.config/dotnetcli.host.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/.template.config/dotnetcli.host.json index a726809b13..aeff794dfa 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/.template.config/dotnetcli.host.json +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/.template.config/dotnetcli.host.json @@ -56,17 +56,14 @@ "isHidden": "true", "longName": "no-tools" }, + "HttpPort": { + "isHidden": true + }, "HttpsPort": { "isHidden": true }, - "KestrelPort": { - "isHidden": true - }, - "IISExpressPort": { - "isHidden": true - }, - "IncludeLaunchSettings": { - "longName": "use-launch-settings", + "ExcludeLaunchSettings": { + "longName": "exclude-launch-settings", "shortName": "" }, "UserSecretsId": { diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/.template.config/template.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/.template.config/template.json index 7e53fe179b..2e07cf706c 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/.template.config/template.json +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/.template.config/template.json @@ -74,7 +74,7 @@ ] }, { - "condition": "(!IncludeLaunchSettings && !WindowsAuth)", + "condition": "(ExcludeLaunchSettings)", "exclude": [ "Properties/launchSettings.json" ] @@ -207,11 +207,11 @@ "defaultValue": "aspnet-Company.WebApplication1-53bc9b9d-9d6a-45d4-8429-2a2761773502", "description": "The ID to use for secrets (use with OrgReadAccess or Individual auth)." }, - "IncludeLaunchSettings": { + "ExcludeLaunchSettings": { "type": "parameter", "datatype": "bool", "defaultValue": "false", - "description": "Whether to include launchSettings.json in the generated template." + "description": "Whether to exclude launchSettings.json in the generated template." }, "skipRestore": { "type": "parameter", @@ -225,10 +225,28 @@ "defaultValue": "false", "description": "Whether or not to include BrowserLink in the project" }, + "HttpPort": { + "type": "parameter", + "datatype": "integer", + "description": "Port number to use for the HTTP endpoint in launchSettings.json." + }, + "HttpPortGenerated": { + "type": "generated", + "generator": "port" + }, + "HttpPortReplacer": { + "type": "generated", + "generator": "coalesce", + "parameters": { + "sourceVariableName": "HttpPort", + "fallbackVariableName": "HttpPortGenerated" + }, + "replaces": "8080" + }, "HttpsPort": { "type": "parameter", "datatype": "integer", - "description": "Port number to use to configure SSL in launchSettings.json." + "description": "Port number to use for the HTTPS endpoint in launchSettings.json." }, "HttpsPortGenerated": { "type": "generated", @@ -245,43 +263,7 @@ "sourceVariableName": "HttpsPort", "fallbackVariableName": "HttpsPortGenerated" }, - "replaces": "43434" - }, - "KestrelPort": { - "type": "parameter", - "datatype": "integer", - "description": "Port number to use to configure Kestrel in launchSettings.json." - }, - "KestrelPortGenerated": { - "type": "generated", - "generator": "port" - }, - "KestrelPortReplacer": { - "type": "generated", - "generator": "coalesce", - "parameters": { - "sourceVariableName": "KestrelPort", - "fallbackVariableName": "KestrelPortGenerated" - }, - "replaces": "5001" - }, - "IISExpressPort": { - "type": "parameter", - "datatype": "integer", - "description": "Port number to use to configure IIS Express in launchSettings.json." - }, - "IISExpressPortGenerated": { - "type": "generated", - "generator": "port" - }, - "IISExpressPortReplacer": { - "type": "generated", - "generator": "coalesce", - "parameters": { - "sourceVariableName": "IISExpressPort", - "fallbackVariableName": "IISExpressPortGenerated" - }, - "replaces": "55556" + "replaces": "44300" }, "OrganizationalAuth": { "type": "computed", diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/.template.config/vs-2017.3.host.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/.template.config/vs-2017.3.host.json index 5fbf904ed4..73a5b598cd 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/.template.config/vs-2017.3.host.json +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/.template.config/vs-2017.3.host.json @@ -50,20 +50,12 @@ } ], "ports": [ - { - "name": "IISExpressPort", - "useHttps": false - }, - { - "name": "KestrelPort", - "useHttps": false - }, { "name": "HttpsPort", "useHttps": true } ], + "excludeLaunchSettings": false, "azureReplyUrlPortName": "HttpsPort", - "includeLaunchSettings": true, "minFullFrameworkVersion": "4.6.1" } diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Properties/launchSettings.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Properties/launchSettings.json new file mode 100644 index 0000000000..0dd1d3c232 --- /dev/null +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "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_HTTPS_PORT": "44300", + "ASPNETCORE_URLS": "https://localhost:44300;http://localhost:8080" + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Startup.cs b/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Startup.cs index bf20114164..04e9d884c5 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Startup.cs +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Startup.cs @@ -18,6 +18,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Http; #endif using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpsPolicy; #if (OrganizationalAuth) using Microsoft.AspNetCore.Mvc.Authorization; #endif @@ -121,8 +122,10 @@ namespace Company.WebApplication1 else { app.UseExceptionHandler("/Error"); + app.UseHsts(); } + app.UseHttpsRedirection(); app.UseStaticFiles(); #if (OrganizationalAuth || IndividualAuth) diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/.template.config/dotnetcli.host.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/.template.config/dotnetcli.host.json index d4a66c0bca..414c2aa60f 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/.template.config/dotnetcli.host.json +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/.template.config/dotnetcli.host.json @@ -60,17 +60,14 @@ "longName": "no-restore", "shortName": "" }, + "HttpPort": { + "isHidden": true + }, "HttpsPort": { "isHidden": true }, - "KestrelPort": { - "isHidden": true - }, - "IISExpressPort": { - "isHidden": true - }, - "IncludeLaunchSettings": { - "longName": "use-launch-settings", + "ExcludeLaunchSettings": { + "longName": "exclude-launch-settings", "shortName": "" }, "UserSecretsId": { diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/.template.config/template.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/.template.config/template.json index b25210b483..be9810cf1c 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/.template.config/template.json +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/.template.config/template.json @@ -47,7 +47,7 @@ ] }, { - "condition": "(!IncludeLaunchSettings && !WindowsAuth)", + "condition": "(ExcludeLaunchSettings)", "exclude": [ "Properties/launchSettings.json" ] @@ -181,11 +181,11 @@ "defaultValue": "aspnet-Company.WebApplication1-53bc9b9d-9d6a-45d4-8429-2a2761773502", "description": "The ID to use for secrets (use with OrgReadAccess or Individual auth)." }, - "IncludeLaunchSettings": { + "ExcludeLaunchSettings": { "type": "parameter", "datatype": "bool", "defaultValue": "false", - "description": "Whether to include launchSettings.json in the generated template." + "description": "Whether to exclude launchSettings.json from the generated template." }, "UseBrowserLink": { "type": "parameter", @@ -193,10 +193,28 @@ "defaultValue": "false", "description": "Whether or not to include BrowserLink in the project" }, + "HttpPort": { + "type": "parameter", + "datatype": "integer", + "description": "Port number to use for the HTTP endpoint in launchSettings.json." + }, + "HttpPortGenerated": { + "type": "generated", + "generator": "port" + }, + "HttpPortReplacer": { + "type": "generated", + "generator": "coalesce", + "parameters": { + "sourceVariableName": "HttpPort", + "fallbackVariableName": "HttpPortGenerated" + }, + "replaces": "8080" + }, "HttpsPort": { "type": "parameter", "datatype": "integer", - "description": "Port number to use to configure SSL in launchSettings.json." + "description": "Port number to use for the HTTPS endpoint in launchSettings.json." }, "HttpsPortGenerated": { "type": "generated", @@ -213,43 +231,7 @@ "sourceVariableName": "HttpsPort", "fallbackVariableName": "HttpsPortGenerated" }, - "replaces": "43434" - }, - "KestrelPort": { - "type": "parameter", - "datatype": "integer", - "description": "Port number to use to configure Kestrel in launchSettings.json." - }, - "KestrelPortGenerated": { - "type": "generated", - "generator": "port" - }, - "KestrelPortReplacer": { - "type": "generated", - "generator": "coalesce", - "parameters": { - "sourceVariableName": "KestrelPort", - "fallbackVariableName": "KestrelPortGenerated" - }, - "replaces": "5001" - }, - "IISExpressPort": { - "type": "parameter", - "datatype": "integer", - "description": "Port number to use to configure IIS Express in launchSettings.json." - }, - "IISExpressPortGenerated": { - "type": "generated", - "generator": "port" - }, - "IISExpressPortReplacer": { - "type": "generated", - "generator": "coalesce", - "parameters": { - "sourceVariableName": "IISExpressPort", - "fallbackVariableName": "IISExpressPortGenerated" - }, - "replaces": "55556" + "replaces": "44300" }, "OrganizationalAuth": { "type": "computed", diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/.template.config/vs-2017.3.host.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/.template.config/vs-2017.3.host.json index f1ee97d12c..75fb5df03c 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/.template.config/vs-2017.3.host.json +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/.template.config/vs-2017.3.host.json @@ -50,20 +50,12 @@ } ], "ports": [ - { - "name": "IISExpressPort", - "useHttps": false - }, - { - "name": "KestrelPort", - "useHttps": false - }, { "name": "HttpsPort", "useHttps": true } ], + "excludeLaunchSettings": false, "azureReplyUrlPortName": "HttpsPort", - "includeLaunchSettings": true, "minFullFrameworkVersion": "4.6.1" } diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Properties/launchSettings.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Properties/launchSettings.json new file mode 100644 index 0000000000..0dd1d3c232 --- /dev/null +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "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_HTTPS_PORT": "44300", + "ASPNETCORE_URLS": "https://localhost:44300;http://localhost:8080" + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Startup.cs b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Startup.cs index 096a7a6ad4..c51a6c0383 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Startup.cs +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Startup.cs @@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; #endif using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; #if (OrganizationalAuth && OrgReadAccess) @@ -95,8 +96,10 @@ namespace Company.WebApplication1 else { app.UseExceptionHandler("/Home/Error"); + app.UseHsts(); } + app.UseHttpsRedirection(); app.UseStaticFiles(); #if (OrganizationalAuth || IndividualAuth) 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 db2415c17b..098d0fa37c 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,6 +1,16 @@ { "$schema": "http://json.schemastore.org/dotnetcli.host", "symbolInfo": { + "HttpPort": { + "isHidden": true + }, + "HttpsPort": { + "isHidden": true + }, + "ExcludeLaunchSettings": { + "longName": "exclude-launch-settings", + "shortName": "" + }, "TargetFrameworkOverride": { "isHidden": "true", "longName": "target-framework-override", 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 78e922460d..184bcafe78 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 @@ -19,7 +19,53 @@ }, "sourceName": "Company.WebApplication1", "preferNameDirectory": true, - "symbols":{ + "symbols": { + "ExcludeLaunchSettings": { + "type": "parameter", + "datatype": "bool", + "defaultValue": "false", + "description": "Whether to exclude launchSettings.json from the generated template." + }, + "HttpPort": { + "type": "parameter", + "datatype": "integer", + "description": "Port number to use for the HTTP endpoint in launchSettings.json." + }, + "HttpPortGenerated": { + "type": "generated", + "generator": "port" + }, + "HttpPortReplacer": { + "type": "generated", + "generator": "coalesce", + "parameters": { + "sourceVariableName": "HttpPort", + "fallbackVariableName": "HttpPortGenerated" + }, + "replaces": "8080" + }, + "HttpsPort": { + "type": "parameter", + "datatype": "integer", + "description": "Port number to use for the HTTPS endpoint in launchSettings.json." + }, + "HttpsPortGenerated": { + "type": "generated", + "generator": "port", + "parameters": { + "low": 44300, + "high": 44399 + } + }, + "HttpsPortReplacer": { + "type": "generated", + "generator": "coalesce", + "parameters": { + "sourceVariableName": "HttpsPort", + "fallbackVariableName": "HttpsPortGenerated" + }, + "replaces": "44300" + }, "RuntimeFrameworkVersion": { "type": "parameter", "replaces": "2.1.0-preview2-25624-02", diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/Properties/launchSettings.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/Properties/launchSettings.json new file mode 100644 index 0000000000..0dd1d3c232 --- /dev/null +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "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_HTTPS_PORT": "44300", + "ASPNETCORE_URLS": "https://localhost:44300;http://localhost:8080" + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/.template.config/dotnetcli.host.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/.template.config/dotnetcli.host.json index 4cd9a7a737..74aa3d3988 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/.template.config/dotnetcli.host.json +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/.template.config/dotnetcli.host.json @@ -44,17 +44,14 @@ "longName": "no-restore", "shortName": "" }, + "HttpPort": { + "isHidden": true + }, "HttpsPort": { "isHidden": true }, - "KestrelPort": { - "isHidden": true - }, - "IISExpressPort": { - "isHidden": true - }, - "IncludeLaunchSettings": { - "longName": "use-launch-settings", + "ExcludeLaunchSettings": { + "longName": "exclude-launch-settings", "shortName": "" }, "UserSecretsId": { diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/.template.config/template.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/.template.config/template.json index 998747907e..b17f92ca51 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/.template.config/template.json +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/.template.config/template.json @@ -33,7 +33,7 @@ ] }, { - "condition": "(!IncludeLaunchSettings && !WindowsAuth)", + "condition": "(ExcludeLaunchSettings)", "exclude": [ "Properties/launchSettings.json" ] @@ -138,16 +138,34 @@ "defaultValue": "aspnet-Company.WebApplication1-53bc9b9d-9d6a-45d4-8429-2a2761773502", "description": "The ID to use for secrets (use with OrgReadAccess or Individual auth)." }, - "IncludeLaunchSettings": { + "ExcludeLaunchSettings": { "type": "parameter", "datatype": "bool", "defaultValue": "false", - "description": "Whether to include launchSettings.json in the generated template." + "description": "Whether to exclude launchSettings.json in the generated template." + }, + "HttpPort": { + "type": "parameter", + "datatype": "integer", + "description": "Port number to use for the HTTP endpoint in launchSettings.json." + }, + "HttpPortGenerated": { + "type": "generated", + "generator": "port" + }, + "HttpPortReplacer": { + "type": "generated", + "generator": "coalesce", + "parameters": { + "sourceVariableName": "HttpPort", + "fallbackVariableName": "HttpPortGenerated" + }, + "replaces": "8080" }, "HttpsPort": { "type": "parameter", "datatype": "integer", - "description": "Port number to use to configure SSL in launchSettings.json." + "description": "Port number to use for the HTTPS endpoint in launchSettings.json." }, "HttpsPortGenerated": { "type": "generated", @@ -164,43 +182,7 @@ "sourceVariableName": "HttpsPort", "fallbackVariableName": "HttpsPortGenerated" }, - "replaces": "43434" - }, - "KestrelPort": { - "type": "parameter", - "datatype": "integer", - "description": "Port number to use to configure Kestrel in launchSettings.json." - }, - "KestrelPortGenerated": { - "type": "generated", - "generator": "port" - }, - "KestrelPortReplacer": { - "type": "generated", - "generator": "coalesce", - "parameters": { - "sourceVariableName": "KestrelPort", - "fallbackVariableName": "KestrelPortGenerated" - }, - "replaces": "5000" - }, - "IISExpressPort": { - "type": "parameter", - "datatype": "integer", - "description": "Port number to use to configure IIS Express in launchSettings.json." - }, - "IISExpressPortGenerated": { - "type": "generated", - "generator": "port" - }, - "IISExpressPortReplacer": { - "type": "generated", - "generator": "coalesce", - "parameters": { - "sourceVariableName": "IISExpressPort", - "fallbackVariableName": "IISExpressPortGenerated" - }, - "replaces": "55556" + "replaces": "44300" }, "OrganizationalAuth": { "type": "computed", diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/.template.config/vs-2017.3.host.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/.template.config/vs-2017.3.host.json index 7a4bc61218..287ddebdad 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/.template.config/vs-2017.3.host.json +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/.template.config/vs-2017.3.host.json @@ -39,20 +39,12 @@ } ], "ports": [ - { - "name": "IISExpressPort", - "useHttps": false - }, - { - "name": "KestrelPort", - "useHttps": false - }, { "name": "HttpsPort", "useHttps": true } ], + "excludeLaunchSettings": false, "azureReplyUrlPortName": "HttpsPort", - "includeLaunchSettings": true, "minFullFrameworkVersion": "4.6.1" } diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/Properties/launchSettings.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/Properties/launchSettings.json new file mode 100644 index 0000000000..0dd1d3c232 --- /dev/null +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "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_HTTPS_PORT": "44300", + "ASPNETCORE_URLS": "https://localhost:44300;http://localhost:8080" + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/Startup.cs b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/Startup.cs index 13a6989a81..6944cbf590 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/Startup.cs +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/Startup.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpsPolicy; #if (OrganizationalAuth || IndividualB2CAuth) using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.JwtBearer; @@ -49,7 +50,12 @@ namespace Company.WebApplication1 { app.UseDeveloperExceptionPage(); } + else + { + app.UseHsts(); + } + app.UseHttpsRedirection(); #if (OrganizationalAuth || IndividualAuth) app.UseAuthentication(); #endif diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/.template.config/dotnetcli.host.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/.template.config/dotnetcli.host.json index 04017b2a43..382744612d 100644 --- a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/.template.config/dotnetcli.host.json +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/.template.config/dotnetcli.host.json @@ -1,6 +1,16 @@ { "$schema": "http://json.schemastore.org/dotnetcli.host", "symbolInfo": { + "HttpPort": { + "isHidden": true + }, + "HttpsPort": { + "isHidden": true + }, + "ExcludeLaunchSettings": { + "longName": "exclude-launch-settings", + "shortName": "" + }, "TargetFrameworkOverride": { "isHidden": "true", "longName": "target-framework-override", 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 e39880158e..c7cd86920e 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 @@ -19,6 +19,52 @@ "sourceName": "Company.WebApplication1", "preferNameDirectory": true, "symbols": { + "ExcludeLaunchSettings": { + "type": "parameter", + "datatype": "bool", + "defaultValue": "false", + "description": "Whether to exclude launchSettings.json from the generated template." + }, + "HttpPort": { + "type": "parameter", + "datatype": "integer", + "description": "Port number to use for the HTTP endpoint in launchSettings.json." + }, + "HttpPortGenerated": { + "type": "generated", + "generator": "port" + }, + "HttpPortReplacer": { + "type": "generated", + "generator": "coalesce", + "parameters": { + "sourceVariableName": "HttpPort", + "fallbackVariableName": "HttpPortGenerated" + }, + "replaces": "8080" + }, + "HttpsPort": { + "type": "parameter", + "datatype": "integer", + "description": "Port number to use for the HTTPS endpoint in launchSettings.json." + }, + "HttpsPortGenerated": { + "type": "generated", + "generator": "port", + "parameters": { + "low": 44300, + "high": 44399 + } + }, + "HttpsPortReplacer": { + "type": "generated", + "generator": "coalesce", + "parameters": { + "sourceVariableName": "HttpsPort", + "fallbackVariableName": "HttpsPortGenerated" + }, + "replaces": "44300" + }, "RuntimeFrameworkVersion": { "type": "parameter", "replaces": "2.1.0-preview2-25624-02", diff --git a/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Properties/launchSettings.json b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Properties/launchSettings.json new file mode 100644 index 0000000000..0dd1d3c232 --- /dev/null +++ b/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "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_HTTPS_PORT": "44300", + "ASPNETCORE_URLS": "https://localhost:44300;http://localhost:8080" + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/Angular-CSharp.csproj.in b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/Angular-CSharp.csproj.in index 5892dd9507..e50c079e01 100644 --- a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/Angular-CSharp.csproj.in +++ b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/Angular-CSharp.csproj.in @@ -19,6 +19,7 @@ + diff --git a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/Microsoft.DotNet.Web.Spa.ProjectTemplates.csproj b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/Microsoft.DotNet.Web.Spa.ProjectTemplates.csproj index e44f0fbc07..3b83293db1 100644 --- a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/Microsoft.DotNet.Web.Spa.ProjectTemplates.csproj +++ b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/Microsoft.DotNet.Web.Spa.ProjectTemplates.csproj @@ -14,6 +14,7 @@ MicrosoftAspNetCoreAllPackageVersion=$(MicrosoftAspNetCoreAllPackageVersion); MicrosoftAspNetCorePackageVersion=$(MicrosoftAspNetCorePackageVersion); + MicrosoftAspNetCoreHttpsPolicyPackageVersion=$(MicrosoftAspNetCoreHttpsPolicyPackageVersion); MicrosoftAspNetCoreMvcPackageVersion=$(MicrosoftAspNetCoreMvcPackageVersion); MicrosoftAspNetCoreSpaServicesPackageVersion=$(MicrosoftAspNetCoreSpaServicesPackageVersion); MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion=$(MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion); diff --git a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/React-CSharp.csproj.in b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/React-CSharp.csproj.in index e67da29826..fd54abde2d 100644 --- a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/React-CSharp.csproj.in +++ b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/React-CSharp.csproj.in @@ -16,6 +16,7 @@ + diff --git a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/ReactRedux-CSharp.csproj.in b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/ReactRedux-CSharp.csproj.in index 7d597d11c8..05835b6070 100644 --- a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/ReactRedux-CSharp.csproj.in +++ b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/ReactRedux-CSharp.csproj.in @@ -19,6 +19,7 @@ + diff --git a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/.template.config/dotnetcli.host.json b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/.template.config/dotnetcli.host.json index c15c6681aa..d27ce640cb 100644 --- a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/.template.config/dotnetcli.host.json +++ b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/.template.config/dotnetcli.host.json @@ -12,6 +12,16 @@ "skipRestore": { "longName": "no-restore", "shortName": "" + }, + "HttpPort": { + "isHidden": true + }, + "HttpsPort": { + "isHidden": true + }, + "ExcludeLaunchSettings": { + "longName": "exclude-launch-settings", + "shortName": "" } } } \ No newline at end of file diff --git a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/.template.config/template.json b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/.template.config/template.json index 89ad08a333..2fd0394a8b 100644 --- a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/.template.config/template.json +++ b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/.template.config/template.json @@ -22,10 +22,64 @@ "target": "./", "exclude": [ ".template.config/**" + ], + "modifiers": [ + { + "condition": "(ExcludeLaunchSettings)", + "exclude": [ + "Properties/launchSettings.json" + ] + } ] } ], "symbols": { + "ExcludeLaunchSettings": { + "type": "parameter", + "datatype": "bool", + "defaultValue": "false", + "description": "Whether to exclude launchSettings.json from the generated template." + }, + "HttpPort": { + "type": "parameter", + "datatype": "integer", + "description": "Port number to use for the HTTP endpoint in launchSettings.json." + }, + "HttpPortGenerated": { + "type": "generated", + "generator": "port" + }, + "HttpPortReplacer": { + "type": "generated", + "generator": "coalesce", + "parameters": { + "sourceVariableName": "HttpPort", + "fallbackVariableName": "HttpPortGenerated" + }, + "replaces": "8080" + }, + "HttpsPort": { + "type": "parameter", + "datatype": "integer", + "description": "Port number to use for the HTTPS endpoint in launchSettings.json." + }, + "HttpsPortGenerated": { + "type": "generated", + "generator": "port", + "parameters": { + "low": 44300, + "high": 44399 + } + }, + "HttpsPortReplacer": { + "type": "generated", + "generator": "coalesce", + "parameters": { + "sourceVariableName": "HttpsPort", + "fallbackVariableName": "HttpsPortGenerated" + }, + "replaces": "44300" + }, "TargetFrameworkOverride": { "type": "parameter", "description": "Overrides the target framework", @@ -74,4 +128,4 @@ "continueOnError": true } ] -} +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/.template.config/vs-2017.3.host.json b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/.template.config/vs-2017.3.host.json index c260ba3c5c..9d7e44237f 100644 --- a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/.template.config/vs-2017.3.host.json +++ b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/.template.config/vs-2017.3.host.json @@ -16,5 +16,12 @@ "uiFilters": [ "oneaspnet" ], + "ports": [ + { + "name": "HttpsPort", + "useHttps": true + } + ], + "excludeLaunchSettings": false, "minFullFrameworkVersion": "4.6.1" } \ No newline at end of file diff --git a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/Properties/launchSettings.json b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/Properties/launchSettings.json new file mode 100644 index 0000000000..0dd1d3c232 --- /dev/null +++ b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "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_HTTPS_PORT": "44300", + "ASPNETCORE_URLS": "https://localhost:44300;http://localhost:8080" + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/Startup.cs b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/Startup.cs index 5120c98180..425636a1c2 100644 --- a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/Startup.cs +++ b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/Startup.cs @@ -37,8 +37,10 @@ namespace AngularSpa else { app.UseExceptionHandler("/Home/Error"); + app.UseHsts(); } + app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSpaStaticFiles(); diff --git a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/.template.config/dotnetcli.host.json b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/.template.config/dotnetcli.host.json index c15c6681aa..d27ce640cb 100644 --- a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/.template.config/dotnetcli.host.json +++ b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/.template.config/dotnetcli.host.json @@ -12,6 +12,16 @@ "skipRestore": { "longName": "no-restore", "shortName": "" + }, + "HttpPort": { + "isHidden": true + }, + "HttpsPort": { + "isHidden": true + }, + "ExcludeLaunchSettings": { + "longName": "exclude-launch-settings", + "shortName": "" } } } \ No newline at end of file diff --git a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/.template.config/template.json b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/.template.config/template.json index 2c6f5dfbd6..c9879baa8a 100644 --- a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/.template.config/template.json +++ b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/.template.config/template.json @@ -22,10 +22,64 @@ "target": "./", "exclude": [ ".template.config/**" + ], + "modifiers": [ + { + "condition": "(ExcludeLaunchSettings)", + "exclude": [ + "Properties/launchSettings.json" + ] + } ] } ], "symbols": { + "ExcludeLaunchSettings": { + "type": "parameter", + "datatype": "bool", + "defaultValue": "false", + "description": "Whether to exclude launchSettings.json from the generated template." + }, + "HttpPort": { + "type": "parameter", + "datatype": "integer", + "description": "Port number to use for the HTTP endpoint in launchSettings.json." + }, + "HttpPortGenerated": { + "type": "generated", + "generator": "port" + }, + "HttpPortReplacer": { + "type": "generated", + "generator": "coalesce", + "parameters": { + "sourceVariableName": "HttpPort", + "fallbackVariableName": "HttpPortGenerated" + }, + "replaces": "8080" + }, + "HttpsPort": { + "type": "parameter", + "datatype": "integer", + "description": "Port number to use for the HTTPS endpoint in launchSettings.json." + }, + "HttpsPortGenerated": { + "type": "generated", + "generator": "port", + "parameters": { + "low": 44300, + "high": 44399 + } + }, + "HttpsPortReplacer": { + "type": "generated", + "generator": "coalesce", + "parameters": { + "sourceVariableName": "HttpsPort", + "fallbackVariableName": "HttpsPortGenerated" + }, + "replaces": "44300" + }, "TargetFrameworkOverride": { "type": "parameter", "description": "Overrides the target framework", diff --git a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/.template.config/vs-2017.3.host.json b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/.template.config/vs-2017.3.host.json index f77016a399..36d4850ec5 100644 --- a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/.template.config/vs-2017.3.host.json +++ b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/.template.config/vs-2017.3.host.json @@ -16,5 +16,12 @@ "uiFilters": [ "oneaspnet" ], + "ports": [ + { + "name": "HttpsPort", + "useHttps": true + } + ], + "excludeLaunchSettings": false, "minFullFrameworkVersion": "4.6.1" } \ No newline at end of file diff --git a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/Properties/launchSettings.json b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/Properties/launchSettings.json new file mode 100644 index 0000000000..0dd1d3c232 --- /dev/null +++ b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "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_HTTPS_PORT": "44300", + "ASPNETCORE_URLS": "https://localhost:44300;http://localhost:8080" + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/Startup.cs b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/Startup.cs index 805a5411e9..a3d692be07 100644 --- a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/Startup.cs +++ b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/Startup.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -37,8 +38,10 @@ namespace ReactSpa else { app.UseExceptionHandler("/Home/Error"); + app.UseHsts(); } + app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSpaStaticFiles(); diff --git a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/.template.config/dotnetcli.host.json b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/.template.config/dotnetcli.host.json index c15c6681aa..6040d19a91 100644 --- a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/.template.config/dotnetcli.host.json +++ b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/.template.config/dotnetcli.host.json @@ -9,6 +9,16 @@ "Framework": { "longName": "framework" }, + "HttpPort": { + "isHidden": true + }, + "HttpsPort": { + "isHidden": true + }, + "ExcludeLaunchSettings": { + "longName": "exclude-launch-settings", + "shortName": "" + }, "skipRestore": { "longName": "no-restore", "shortName": "" diff --git a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/.template.config/template.json b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/.template.config/template.json index 931958cada..a79b46c205 100644 --- a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/.template.config/template.json +++ b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/.template.config/template.json @@ -22,10 +22,64 @@ "target": "./", "exclude": [ ".template.config/**" + ], + "modifiers": [ + { + "condition": "(ExcludeLaunchSettings)", + "exclude": [ + "Properties/launchSettings.json" + ] + } ] } ], "symbols": { + "ExcludeLaunchSettings": { + "type": "parameter", + "datatype": "bool", + "defaultValue": "false", + "description": "Whether to exclude launchSettings.json from the generated template." + }, + "HttpPort": { + "type": "parameter", + "datatype": "integer", + "description": "Port number to use for the HTTP endpoint in launchSettings.json." + }, + "HttpPortGenerated": { + "type": "generated", + "generator": "port" + }, + "HttpPortReplacer": { + "type": "generated", + "generator": "coalesce", + "parameters": { + "sourceVariableName": "HttpPort", + "fallbackVariableName": "HttpPortGenerated" + }, + "replaces": "8080" + }, + "HttpsPort": { + "type": "parameter", + "datatype": "integer", + "description": "Port number to use for the HTTPS endpoint in launchSettings.json." + }, + "HttpsPortGenerated": { + "type": "generated", + "generator": "port", + "parameters": { + "low": 44300, + "high": 44399 + } + }, + "HttpsPortReplacer": { + "type": "generated", + "generator": "coalesce", + "parameters": { + "sourceVariableName": "HttpsPort", + "fallbackVariableName": "HttpsPortGenerated" + }, + "replaces": "44300" + }, "TargetFrameworkOverride": { "type": "parameter", "description": "Overrides the target framework", diff --git a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/.template.config/vs-2017.3.host.json b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/.template.config/vs-2017.3.host.json index 02f9d5218c..e54d93f5d9 100644 --- a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/.template.config/vs-2017.3.host.json +++ b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/.template.config/vs-2017.3.host.json @@ -16,5 +16,12 @@ "uiFilters": [ "oneaspnet" ], + "ports": [ + { + "name": "HttpsPort", + "useHttps": true + } + ], + "excludeLaunchSettings": false, "minFullFrameworkVersion": "4.6.1" } \ No newline at end of file diff --git a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/Properties/launchSettings.json b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/Properties/launchSettings.json new file mode 100644 index 0000000000..0dd1d3c232 --- /dev/null +++ b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "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_HTTPS_PORT": "44300", + "ASPNETCORE_URLS": "https://localhost:44300;http://localhost:8080" + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/Startup.cs b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/Startup.cs index c1dcf935f1..683601aa2d 100644 --- a/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/Startup.cs +++ b/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/Startup.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -37,8 +38,10 @@ namespace ReactReduxSpa else { app.UseExceptionHandler("/Home/Error"); + app.UseHsts(); } + app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSpaStaticFiles(); diff --git a/test/Templates.Test/Helpers/AspNetProcess.cs b/test/Templates.Test/Helpers/AspNetProcess.cs index 0aab347cd4..f9579f4548 100644 --- a/test/Templates.Test/Helpers/AspNetProcess.cs +++ b/test/Templates.Test/Helpers/AspNetProcess.cs @@ -8,6 +8,8 @@ using System.Net.Http; using Microsoft.Extensions.CommandLineUtils; using Xunit; using Xunit.Abstractions; +using Microsoft.AspNetCore.Certificates.Generation; +using System.Threading; namespace Templates.Test.Helpers { @@ -15,16 +17,28 @@ namespace Templates.Test.Helpers { private const string DefaultFramework = "netcoreapp2.0"; private const string ListeningMessagePrefix = "Now listening on: "; + private static int Port = 5000 + new Random().Next(3000); private readonly ProcessEx _process; private readonly Uri _listeningUri; private readonly HttpClient _httpClient; private readonly ITestOutputHelper _output; + private readonly int _httpsPort; + private readonly int _httpPort; public AspNetProcess(ITestOutputHelper output, string workingDirectory, string projectName, string targetFrameworkOverride, bool publish) { _output = output; - _httpClient = new HttpClient(); + _httpClient = new HttpClient(new HttpClientHandler() + { + AllowAutoRedirect = true, + UseCookies = true, + CookieContainer = new CookieContainer(), + ServerCertificateCustomValidationCallback = (m, c, ch, p) => true + }); + + var now = DateTimeOffset.Now; + new CertificateManager().EnsureAspNetCoreHttpsDevelopmentCertificate(now, now.AddYears(1)); var framework = string.IsNullOrEmpty(targetFrameworkOverride) ? DefaultFramework : targetFrameworkOverride; if (publish) @@ -48,9 +62,12 @@ namespace Templates.Test.Helpers .WaitForExit(assertSuccess: true); } + _httpPort = Interlocked.Increment(ref Port); + _httpsPort = Interlocked.Increment(ref Port); var envVars = new Dictionary { - { "ASPNETCORE_URLS", "http://127.0.0.1:0" } + { "ASPNETCORE_URLS", $"http://localhost:{_httpPort};https://localhost:{_httpsPort}" }, + { "ASPNETCORE_HTTPS_PORT", $"{_httpsPort}" } }; if (!publish) diff --git a/test/Templates.Test/Helpers/TemplateTestBase.cs b/test/Templates.Test/Helpers/TemplateTestBase.cs index a4c9c40c46..6c546a5696 100644 --- a/test/Templates.Test/Helpers/TemplateTestBase.cs +++ b/test/Templates.Test/Helpers/TemplateTestBase.cs @@ -17,6 +17,7 @@ namespace Templates.Test private static object DotNetNewLock = new object(); protected string ProjectName { get; set; } + protected string ProjectGuid { get; set; } protected string TemplateOutputDir { get; private set; } protected ITestOutputHelper Output { get; private set; } @@ -25,7 +26,8 @@ namespace Templates.Test TemplatePackageInstaller.EnsureTemplatePackagesWereReinstalled(output); Output = output; - ProjectName = Guid.NewGuid().ToString().Replace("-", ""); + ProjectGuid = Guid.NewGuid().ToString("N"); + ProjectName = $"AspNet.Template.{ProjectGuid}"; var assemblyPath = GetType().GetTypeInfo().Assembly.CodeBase; var assemblyUri = new Uri(assemblyPath, UriKind.Absolute); diff --git a/test/Templates.Test/Helpers/WebDriverFactory.cs b/test/Templates.Test/Helpers/WebDriverFactory.cs index 63b0e38c85..b3c27e859d 100644 --- a/test/Templates.Test/Helpers/WebDriverFactory.cs +++ b/test/Templates.Test/Helpers/WebDriverFactory.cs @@ -1,17 +1,24 @@ -using OpenQA.Selenium; -using OpenQA.Selenium.Edge; -using OpenQA.Selenium.Firefox; -using System; +using System; using System.IO; using System.Runtime.InteropServices; using System.Text.RegularExpressions; +using OpenQA.Selenium; +using OpenQA.Selenium.Edge; +using OpenQA.Selenium.Firefox; namespace Templates.Test.Helpers { public static class WebDriverFactory { + // Maximum time any action performed by WebDriver will wait before failing. + // Any action will have to be completed in at most 10 seconds. + // Providing a smaller value won't improve the speed of the tests in any + // significant way and will make them more prone to fail on slower drivers. + private const int DefaultMaxWaitTimeInSeconds = 10; + public static bool HostSupportsBrowserAutomation - => IsAppVeyor || OSSupportsEdge(); + => string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("ASPNETCORE_BROWSER_AUTOMATION_DISABLED")) && + (IsAppVeyor || OSSupportsEdge()); private static bool IsAppVeyor => Environment.GetEnvironmentVariables().Contains("APPVEYOR"); @@ -21,16 +28,24 @@ namespace Templates.Test.Helpers // Where possible, it's preferable to use Edge because it's // far faster to automate than Chrome/Firefox. But on AppVeyor // only Firefox is available. - var result = IsAppVeyor ? CreateFirefoxDriver() : CreateEdgeDriver(); - result.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1); + var result = (IsAppVeyor || UseFirefox()) ? CreateFirefoxDriver() : CreateEdgeDriver(); + result.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(DefaultMaxWaitTimeInSeconds); return result; + + bool UseFirefox() => !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("ASPNETCORE_BROWSER_AUTOMATION_FIREFOX")); } private static IWebDriver CreateEdgeDriver() => new EdgeDriver(EdgeDriverService.CreateDefaultService(BinDir)); private static IWebDriver CreateFirefoxDriver() - => new FirefoxDriver(FirefoxDriverService.CreateDefaultService(BinDir)); + => new FirefoxDriver( + FirefoxDriverService.CreateDefaultService(BinDir), + new FirefoxOptions() + { + AcceptInsecureCertificates = true + }, + TimeSpan.FromSeconds(DefaultMaxWaitTimeInSeconds)); private static string BinDir => Path.GetDirectoryName(typeof(WebDriverFactory).Assembly.Location); @@ -45,7 +60,7 @@ namespace Templates.Test.Helpers private static bool OSSupportsEdge() { var windowsVersion = GetWindowsVersion(); - return (windowsVersion >= 10 && windowsVersion < 2000) + return (windowsVersion >= DefaultMaxWaitTimeInSeconds && windowsVersion < 2000) || (windowsVersion >= 2016); } } diff --git a/test/Templates.Test/MvcTemplateTest.cs b/test/Templates.Test/MvcTemplateTest.cs index fdc51a4cec..415f396eb1 100644 --- a/test/Templates.Test/MvcTemplateTest.cs +++ b/test/Templates.Test/MvcTemplateTest.cs @@ -24,7 +24,7 @@ namespace Templates.Test [InlineData(null)] [InlineData("F#")] public void MvcTemplate_NoAuth_Works_NetCore(string languageOverride) - => MvcTemplate_NoAuthImpl(null, languageOverride); + => MvcTemplate_NoAuthImpl(null, languageOverride: languageOverride); private void MvcTemplate_NoAuthImpl(string targetFrameworkOverride, string languageOverride) { diff --git a/test/Templates.Test/SpaTemplateTest/SpaTemplateTestBase.cs b/test/Templates.Test/SpaTemplateTest/SpaTemplateTestBase.cs index d9a62356c5..7c9af71b59 100644 --- a/test/Templates.Test/SpaTemplateTest/SpaTemplateTestBase.cs +++ b/test/Templates.Test/SpaTemplateTest/SpaTemplateTestBase.cs @@ -62,7 +62,7 @@ namespace Templates.Test.SpaTemplateTest private void TestBasicNavigation(IWebDriver browser) { // element gets project ID injected into it during template execution - Assert.Contains(ProjectName, browser.Title); + Assert.Contains(ProjectGuid, browser.Title); // Initially displays the home page Assert.Equal("Hello, world!", browser.GetText("h1")); diff --git a/test/Templates.Test/Templates.Test.csproj b/test/Templates.Test/Templates.Test.csproj index e0b09e10f3..ce0d03dcfb 100644 --- a/test/Templates.Test/Templates.Test.csproj +++ b/test/Templates.Test/Templates.Test.csproj @@ -2,10 +2,12 @@ <PropertyGroup> <TargetFramework>netcoreapp2.0</TargetFramework> + <DefineConstants>$(DefineConstants);XPLAT</DefineConstants> </PropertyGroup> <ItemGroup> <PackageReference Include="Internal.AspNetCore.Sdk" Version="$(InternalAspNetCoreSdkPackageVersion)" /> + <PackageReference Include="Microsoft.AspNetCore.Certificates.Generation.Sources" Version="$(MicrosoftAspNetCoreCertificatesGenerationSourcesPackageVersion)" /> <PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" /> <PackageReference Include="Microsoft.Extensions.CommandLineUtils.Sources" Version="$(MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion)" /> <PackageReference Include="Microsoft.Extensions.Process.Sources" Version="$(MicrosoftExtensionsProcessSourcesPackageVersion)" PrivateAssets="All" />