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.
This commit is contained in:
Javier Calvarro Nelson 2017-11-16 14:27:12 -08:00
parent bc95a4a6c1
commit 4d2e642b94
75 changed files with 1099 additions and 222 deletions

1
.gitignore vendored
View File

@ -32,7 +32,6 @@ nuget.exe
*.sln.ide *.sln.ide
node_modules node_modules
**/[Cc]ompiler/[Rr]esources/**/*.js **/[Cc]ompiler/[Rr]esources/**/*.js
*launchSettings.json
.build/ .build/
.testPublish/ .testPublish/
.vscode .vscode

View File

@ -8,7 +8,9 @@
<MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>2.1.0-preview1-27644</MicrosoftAspNetCoreAuthenticationCookiesPackageVersion> <MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>2.1.0-preview1-27644</MicrosoftAspNetCoreAuthenticationCookiesPackageVersion>
<MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion>2.1.0-preview1-27644</MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion> <MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion>2.1.0-preview1-27644</MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion>
<MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion>2.1.0-preview1-27644</MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion> <MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion>2.1.0-preview1-27644</MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion>
<MicrosoftAspNetCoreCertificatesGenerationSourcesPackageVersion>2.1.0-preview1-27644</MicrosoftAspNetCoreCertificatesGenerationSourcesPackageVersion>
<MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion>2.1.0-preview1-27644</MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion> <MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion>2.1.0-preview1-27644</MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion>
<MicrosoftAspNetCoreHttpsPolicyPackageVersion>2.1.0-preview1-27644</MicrosoftAspNetCoreHttpsPolicyPackageVersion>
<MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion>2.1.0-preview1-27644</MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion> <MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion>2.1.0-preview1-27644</MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion>
<MicrosoftAspNetCoreMvcPackageVersion>2.1.0-preview1-27644</MicrosoftAspNetCoreMvcPackageVersion> <MicrosoftAspNetCoreMvcPackageVersion>2.1.0-preview1-27644</MicrosoftAspNetCoreMvcPackageVersion>
<MicrosoftAspNetCoreMvcRazorViewCompilationPackageVersion>2.1.0-preview1-27644</MicrosoftAspNetCoreMvcRazorViewCompilationPackageVersion> <MicrosoftAspNetCoreMvcRazorViewCompilationPackageVersion>2.1.0-preview1-27644</MicrosoftAspNetCoreMvcRazorViewCompilationPackageVersion>
@ -35,9 +37,9 @@
<MicrosoftVisualStudioWebCodeGenerationToolsPackageVersion>2.1.0-preview1-27644</MicrosoftVisualStudioWebCodeGenerationToolsPackageVersion> <MicrosoftVisualStudioWebCodeGenerationToolsPackageVersion>2.1.0-preview1-27644</MicrosoftVisualStudioWebCodeGenerationToolsPackageVersion>
<NETStandardLibraryPackageVersion>2.0.0</NETStandardLibraryPackageVersion> <NETStandardLibraryPackageVersion>2.0.0</NETStandardLibraryPackageVersion>
<SeleniumFirefoxWebDriverPackageVersion>0.19.0</SeleniumFirefoxWebDriverPackageVersion> <SeleniumFirefoxWebDriverPackageVersion>0.19.0</SeleniumFirefoxWebDriverPackageVersion>
<SeleniumSupportPackageVersion>3.6.0</SeleniumSupportPackageVersion> <SeleniumSupportPackageVersion>3.7.0</SeleniumSupportPackageVersion>
<SeleniumWebDriverMicrosoftDriverPackageVersion>16.16299.0</SeleniumWebDriverMicrosoftDriverPackageVersion> <SeleniumWebDriverMicrosoftDriverPackageVersion>16.16299.0</SeleniumWebDriverMicrosoftDriverPackageVersion>
<SeleniumWebDriverPackageVersion>3.6.0</SeleniumWebDriverPackageVersion> <SeleniumWebDriverPackageVersion>3.7.0</SeleniumWebDriverPackageVersion>
<SystemSecurityPermissionsPackageVersion>4.4.0</SystemSecurityPermissionsPackageVersion> <SystemSecurityPermissionsPackageVersion>4.4.0</SystemSecurityPermissionsPackageVersion>
<XunitAnalyzersPackageVersion>0.7.0</XunitAnalyzersPackageVersion> <XunitAnalyzersPackageVersion>0.7.0</XunitAnalyzersPackageVersion>
<XunitPackageVersion>2.3.0</XunitPackageVersion> <XunitPackageVersion>2.3.0</XunitPackageVersion>

View File

@ -13,6 +13,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkOverride)' != ''"> <ItemGroup Condition="'$(TargetFrameworkOverride)' != ''">
<PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="${MicrosoftAspNetCoreSpaServicesPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="${MicrosoftAspNetCoreSpaServicesPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="${MicrosoftAspNetCoreStaticFilesPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="${MicrosoftAspNetCoreStaticFilesPackageVersion}" />

View File

@ -13,6 +13,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkOverride)' != ''"> <ItemGroup Condition="'$(TargetFrameworkOverride)' != ''">
<PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="${MicrosoftAspNetCoreSpaServicesPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="${MicrosoftAspNetCoreSpaServicesPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="${MicrosoftAspNetCoreStaticFilesPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="${MicrosoftAspNetCoreStaticFilesPackageVersion}" />

View File

@ -13,6 +13,7 @@
<GeneratedContentProperties> <GeneratedContentProperties>
MicrosoftAspNetCoreAllPackageVersion=$(MicrosoftAspNetCoreAllPackageVersion); MicrosoftAspNetCoreAllPackageVersion=$(MicrosoftAspNetCoreAllPackageVersion);
MicrosoftAspNetCoreMvcPackageVersion=$(MicrosoftAspNetCoreMvcPackageVersion); MicrosoftAspNetCoreMvcPackageVersion=$(MicrosoftAspNetCoreMvcPackageVersion);
MicrosoftAspNetCoreHttpsPolicyPackageVersion=$(MicrosoftAspNetCoreHttpsPolicyPackageVersion);
MicrosoftAspNetCorePackageVersion=$(MicrosoftAspNetCorePackageVersion); MicrosoftAspNetCorePackageVersion=$(MicrosoftAspNetCorePackageVersion);
MicrosoftAspNetCoreSpaServicesPackageVersion=$(MicrosoftAspNetCoreSpaServicesPackageVersion); MicrosoftAspNetCoreSpaServicesPackageVersion=$(MicrosoftAspNetCoreSpaServicesPackageVersion);
MicrosoftAspNetCoreStaticFilesPackageVersion=$(MicrosoftAspNetCoreStaticFilesPackageVersion); MicrosoftAspNetCoreStaticFilesPackageVersion=$(MicrosoftAspNetCoreStaticFilesPackageVersion);

View File

@ -13,6 +13,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkOverride)' != ''"> <ItemGroup Condition="'$(TargetFrameworkOverride)' != ''">
<PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="${MicrosoftAspNetCoreSpaServicesPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="${MicrosoftAspNetCoreSpaServicesPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="${MicrosoftAspNetCoreStaticFilesPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="${MicrosoftAspNetCoreStaticFilesPackageVersion}" />

View File

@ -12,6 +12,16 @@
"skipRestore": { "skipRestore": {
"longName": "no-restore", "longName": "no-restore",
"shortName": "" "shortName": ""
},
"HttpPort": {
"isHidden": true
},
"HttpsPort": {
"isHidden": true
},
"ExcludeLaunchSettings": {
"longName": "exclude-launch-settings",
"shortName": ""
} }
} }
} }

View File

@ -22,10 +22,64 @@
"target": "./", "target": "./",
"exclude": [ "exclude": [
".template.config/**" ".template.config/**"
],
"modifiers": [
{
"condition": "(ExcludeLaunchSettings)",
"exclude": [
"Properties/launchSettings.json"
]
}
] ]
} }
], ],
"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"
},
"TargetFrameworkOverride": { "TargetFrameworkOverride": {
"type": "parameter", "type": "parameter",
"description": "Overrides the target framework", "description": "Overrides the target framework",

View File

@ -16,5 +16,12 @@
"uiFilters": [ "uiFilters": [
"oneaspnet" "oneaspnet"
], ],
"ports": [
{
"name": "HttpsPort",
"useHttps": true
}
],
"excludeLaunchSettings": false,
"minFullFrameworkVersion": "4.6.1" "minFullFrameworkVersion": "4.6.1"
} }

View File

@ -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"
}
}
}
}

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.SpaServices.Webpack; using Microsoft.AspNetCore.SpaServices.Webpack;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -39,8 +40,10 @@ namespace AureliaSpa
else else
{ {
app.UseExceptionHandler("/Home/Error"); app.UseExceptionHandler("/Home/Error");
app.UseHsts();
} }
app.UseHttpsRedirection();
app.UseStaticFiles(); app.UseStaticFiles();
app.UseMvc(routes => app.UseMvc(routes =>

View File

@ -12,6 +12,16 @@
"skipRestore": { "skipRestore": {
"longName": "no-restore", "longName": "no-restore",
"shortName": "" "shortName": ""
},
"HttpPort": {
"isHidden": true
},
"HttpsPort": {
"isHidden": true
},
"ExcludeLaunchSettings": {
"longName": "exclude-launch-settings",
"shortName": ""
} }
} }
} }

View File

@ -22,10 +22,64 @@
"target": "./", "target": "./",
"exclude": [ "exclude": [
".template.config/**" ".template.config/**"
],
"modifiers": [
{
"condition": "(ExcludeLaunchSettings)",
"exclude": [
"Properties/launchSettings.json"
]
}
] ]
} }
], ],
"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"
},
"TargetFrameworkOverride": { "TargetFrameworkOverride": {
"type": "parameter", "type": "parameter",
"description": "Overrides the target framework", "description": "Overrides the target framework",

View File

@ -16,5 +16,12 @@
"uiFilters": [ "uiFilters": [
"oneaspnet" "oneaspnet"
], ],
"ports": [
{
"name": "HttpsPort",
"useHttps": true
}
],
"excludeLaunchSettings": false,
"minFullFrameworkVersion": "4.6.1" "minFullFrameworkVersion": "4.6.1"
} }

View File

@ -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"
}
}
}
}

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.SpaServices.Webpack; using Microsoft.AspNetCore.SpaServices.Webpack;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -39,8 +40,10 @@ namespace KnockoutSpa
else else
{ {
app.UseExceptionHandler("/Home/Error"); app.UseExceptionHandler("/Home/Error");
app.UseHsts();
} }
app.UseHttpsRedirection();
app.UseStaticFiles(); app.UseStaticFiles();
app.UseMvc(routes => app.UseMvc(routes =>

View File

@ -12,6 +12,16 @@
"skipRestore": { "skipRestore": {
"longName": "no-restore", "longName": "no-restore",
"shortName": "" "shortName": ""
},
"HttpPort": {
"isHidden": true
},
"HttpsPort": {
"isHidden": true
},
"ExcludeLaunchSettings": {
"longName": "exclude-launch-settings",
"shortName": ""
} }
} }
} }

View File

@ -22,10 +22,64 @@
"target": "./", "target": "./",
"exclude": [ "exclude": [
".template.config/**" ".template.config/**"
],
"modifiers": [
{
"condition": "(ExcludeLaunchSettings)",
"exclude": [
"Properties/launchSettings.json"
]
}
] ]
} }
], ],
"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"
},
"TargetFrameworkOverride": { "TargetFrameworkOverride": {
"type": "parameter", "type": "parameter",
"description": "Overrides the target framework", "description": "Overrides the target framework",

View File

@ -16,5 +16,12 @@
"uiFilters": [ "uiFilters": [
"oneaspnet" "oneaspnet"
], ],
"ports": [
{
"name": "HttpsPort",
"useHttps": true
}
],
"excludeLaunchSettings": false,
"minFullFrameworkVersion": "4.6.1" "minFullFrameworkVersion": "4.6.1"
} }

View File

@ -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"
}
}
}
}

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.SpaServices.Webpack; using Microsoft.AspNetCore.SpaServices.Webpack;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -39,8 +40,10 @@ namespace VueSpa
else else
{ {
app.UseExceptionHandler("/Home/Error"); app.UseExceptionHandler("/Home/Error");
app.UseHsts();
} }
app.UseHttpsRedirection();
app.UseStaticFiles(); app.UseStaticFiles();
app.UseMvc(routes => app.UseMvc(routes =>

View File

@ -18,6 +18,7 @@
MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion=$(MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion); MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion=$(MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion);
MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion=$(MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion); MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion=$(MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion);
MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion=$(MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion); MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion=$(MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion);
MicrosoftAspNetCoreHttpsPolicyPackageVersion=$(MicrosoftAspNetCoreHttpsPolicyPackageVersion);
MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion=$(MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion); MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion=$(MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion);
MicrosoftAspNetCoreMvcPackageVersion=$(MicrosoftAspNetCoreMvcPackageVersion); MicrosoftAspNetCoreMvcPackageVersion=$(MicrosoftAspNetCoreMvcPackageVersion);
MicrosoftAspNetCoreMvcRazorViewCompilationPackageVersion=$(MicrosoftAspNetCoreMvcRazorViewCompilationPackageVersion); MicrosoftAspNetCoreMvcRazorViewCompilationPackageVersion=$(MicrosoftAspNetCoreMvcRazorViewCompilationPackageVersion);

View File

@ -25,6 +25,7 @@
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="${MicrosoftAspNetCoreAuthenticationCookiesPackageVersion}" Condition="'$(IndividualAuth)' == 'True' OR '$(OrganizationalAuth)' == 'True'" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="${MicrosoftAspNetCoreAuthenticationCookiesPackageVersion}" Condition="'$(IndividualAuth)' == 'True' OR '$(OrganizationalAuth)' == 'True'" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="${MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion}" Condition="'$(OrganizationalAuth)' == 'True' OR '$(IndividualB2CAuth)' == 'True'" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="${MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion}" Condition="'$(OrganizationalAuth)' == 'True' OR '$(IndividualB2CAuth)' == 'True'" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="${MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" /> <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="${MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="${MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" /> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="${MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="${MicrosoftAspNetCoreMvcRazorViewCompilationPackageVersion}" PrivateAssets="All" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="${MicrosoftAspNetCoreMvcRazorViewCompilationPackageVersion}" PrivateAssets="All" />

View File

@ -26,6 +26,7 @@
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="${MicrosoftAspNetCoreAuthenticationCookiesPackageVersion}" Condition="'$(IndividualAuth)' == 'True' OR '$(OrganizationalAuth)' == 'True'" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="${MicrosoftAspNetCoreAuthenticationCookiesPackageVersion}" Condition="'$(IndividualAuth)' == 'True' OR '$(OrganizationalAuth)' == 'True'" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="${MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion}" Condition="'$(OrganizationalAuth)' == 'True' OR '$(IndividualB2CAuth)' == 'True'" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="${MicrosoftAspNetCoreAuthenticationOpenIdConnectPackageVersion}" Condition="'$(OrganizationalAuth)' == 'True' OR '$(IndividualB2CAuth)' == 'True'" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="${MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" /> <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="${MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="${MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" /> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="${MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="${MicrosoftAspNetCoreMvcRazorViewCompilationPackageVersion}" PrivateAssets="All" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="${MicrosoftAspNetCoreMvcRazorViewCompilationPackageVersion}" PrivateAssets="All" />

View File

@ -21,6 +21,7 @@
<ItemGroup Condition="'$(TargetFrameworkOverride)' != ''"> <ItemGroup Condition="'$(TargetFrameworkOverride)' != ''">
<PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="${MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion}" Condition="'$(OrganizationalAuth)' == 'True' OR '$(IndividualB2CAuth)' == 'True'" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="${MicrosoftAspNetCoreAuthenticationJwtBearerPackageVersion}" Condition="'$(OrganizationalAuth)' == 'True' OR '$(IndividualB2CAuth)' == 'True'" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" />
</ItemGroup> </ItemGroup>

View File

@ -13,14 +13,14 @@
"longName": "no-restore", "longName": "no-restore",
"shortName": "" "shortName": ""
}, },
"KestrelPort": { "HttpPort": {
"isHidden": true "isHidden": true
}, },
"IISExpressPort": { "HttpsPort": {
"isHidden": true "isHidden": true
}, },
"IncludeLaunchSettings": { "ExcludeLaunchSettings": {
"longName": "use-launch-settings", "longName": "exclude-launch-settings",
"shortName": "" "shortName": ""
}, },
"RuntimeFrameworkVersion": { "RuntimeFrameworkVersion": {

View File

@ -26,7 +26,7 @@
{ {
"modifiers": [ "modifiers": [
{ {
"condition": "(!IncludeLaunchSettings)", "condition": "(ExcludeLaunchSettings)",
"exclude": [ "exclude": [
"Properties/launchSettings.json" "Properties/launchSettings.json"
] ]
@ -41,47 +41,51 @@
"datatype": "string", "datatype": "string",
"defaultValue": "2.1.0-preview2-25624-02" "defaultValue": "2.1.0-preview2-25624-02"
}, },
"IncludeLaunchSettings": { "ExcludeLaunchSettings": {
"type": "parameter", "type": "parameter",
"datatype": "bool", "datatype": "bool",
"defaultValue": "false", "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", "type": "parameter",
"datatype": "integer", "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", "type": "generated",
"generator": "port" "generator": "port"
}, },
"KestrelPortReplacer": { "HttpPortReplacer": {
"type": "generated", "type": "generated",
"generator": "coalesce", "generator": "coalesce",
"parameters": { "parameters": {
"sourceVariableName": "KestrelPort", "sourceVariableName": "HttpPort",
"fallbackVariableName": "KestrelPortGenerated" "fallbackVariableName": "HttpPortGenerated"
}, },
"replaces": "5000" "replaces": "8080"
}, },
"IISExpressPort": { "HttpsPort": {
"type": "parameter", "type": "parameter",
"datatype": "integer", "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", "type": "generated",
"generator": "port" "generator": "port",
"parameters": {
"low": 44300,
"high": 44399
}
}, },
"IISExpressPortReplacer": { "HttpsPortReplacer": {
"type": "generated", "type": "generated",
"generator": "coalesce", "generator": "coalesce",
"parameters": { "parameters": {
"sourceVariableName": "IISExpressPort", "sourceVariableName": "HttpsPort",
"fallbackVariableName": "IISExpressPortGenerated" "fallbackVariableName": "HttpsPortGenerated"
}, },
"replaces": "55556" "replaces": "44300"
}, },
"TargetFrameworkOverride": { "TargetFrameworkOverride": {
"type": "parameter", "type": "parameter",

View File

@ -18,14 +18,10 @@
"legacyTemplateIdentity": "Microsoft.NetCore.CSharp.EmptyWeb", "legacyTemplateIdentity": "Microsoft.NetCore.CSharp.EmptyWeb",
"ports": [ "ports": [
{ {
"name": "IISExpressPort", "name": "HttpsPort",
"useHttps": false "useHttps": true
},
{
"name": "KestrelPort",
"useHttps": false
} }
], ],
"includeLaunchSettings": true, "excludeLaunchSettings": false,
"minFullFrameworkVersion": "4.6.1" "minFullFrameworkVersion": "4.6.1"
} }

View File

@ -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"
}
}
}
}

View File

@ -56,17 +56,14 @@
"isHidden": "true", "isHidden": "true",
"longName": "no-tools" "longName": "no-tools"
}, },
"HttpPort": {
"isHidden": true
},
"HttpsPort": { "HttpsPort": {
"isHidden": true "isHidden": true
}, },
"KestrelPort": { "ExcludeLaunchSettings": {
"isHidden": true "longName": "exclude-launch-settings",
},
"IISExpressPort": {
"isHidden": true
},
"IncludeLaunchSettings": {
"longName": "use-launch-settings",
"shortName": "" "shortName": ""
}, },
"UserSecretsId": { "UserSecretsId": {

View File

@ -74,7 +74,7 @@
] ]
}, },
{ {
"condition": "(!IncludeLaunchSettings && !WindowsAuth)", "condition": "(ExcludeLaunchSettings)",
"exclude": [ "exclude": [
"Properties/launchSettings.json" "Properties/launchSettings.json"
] ]
@ -207,11 +207,11 @@
"defaultValue": "aspnet-Company.WebApplication1-53bc9b9d-9d6a-45d4-8429-2a2761773502", "defaultValue": "aspnet-Company.WebApplication1-53bc9b9d-9d6a-45d4-8429-2a2761773502",
"description": "The ID to use for secrets (use with OrgReadAccess or Individual auth)." "description": "The ID to use for secrets (use with OrgReadAccess or Individual auth)."
}, },
"IncludeLaunchSettings": { "ExcludeLaunchSettings": {
"type": "parameter", "type": "parameter",
"datatype": "bool", "datatype": "bool",
"defaultValue": "false", "defaultValue": "false",
"description": "Whether to include launchSettings.json in the generated template." "description": "Whether to exclude launchSettings.json in the generated template."
}, },
"skipRestore": { "skipRestore": {
"type": "parameter", "type": "parameter",
@ -225,10 +225,28 @@
"defaultValue": "false", "defaultValue": "false",
"description": "Whether or not to include BrowserLink in the project" "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": { "HttpsPort": {
"type": "parameter", "type": "parameter",
"datatype": "integer", "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": { "HttpsPortGenerated": {
"type": "generated", "type": "generated",
@ -245,43 +263,7 @@
"sourceVariableName": "HttpsPort", "sourceVariableName": "HttpsPort",
"fallbackVariableName": "HttpsPortGenerated" "fallbackVariableName": "HttpsPortGenerated"
}, },
"replaces": "43434" "replaces": "44300"
},
"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"
}, },
"OrganizationalAuth": { "OrganizationalAuth": {
"type": "computed", "type": "computed",

View File

@ -50,20 +50,12 @@
} }
], ],
"ports": [ "ports": [
{
"name": "IISExpressPort",
"useHttps": false
},
{
"name": "KestrelPort",
"useHttps": false
},
{ {
"name": "HttpsPort", "name": "HttpsPort",
"useHttps": true "useHttps": true
} }
], ],
"excludeLaunchSettings": false,
"azureReplyUrlPortName": "HttpsPort", "azureReplyUrlPortName": "HttpsPort",
"includeLaunchSettings": true,
"minFullFrameworkVersion": "4.6.1" "minFullFrameworkVersion": "4.6.1"
} }

View File

@ -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"
}
}
}
}

View File

@ -18,6 +18,7 @@ using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
#endif #endif
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
#if (OrganizationalAuth) #if (OrganizationalAuth)
using Microsoft.AspNetCore.Mvc.Authorization; using Microsoft.AspNetCore.Mvc.Authorization;
#endif #endif
@ -121,8 +122,10 @@ namespace Company.WebApplication1
else else
{ {
app.UseExceptionHandler("/Error"); app.UseExceptionHandler("/Error");
app.UseHsts();
} }
app.UseHttpsRedirection();
app.UseStaticFiles(); app.UseStaticFiles();
#if (OrganizationalAuth || IndividualAuth) #if (OrganizationalAuth || IndividualAuth)

View File

@ -60,17 +60,14 @@
"longName": "no-restore", "longName": "no-restore",
"shortName": "" "shortName": ""
}, },
"HttpPort": {
"isHidden": true
},
"HttpsPort": { "HttpsPort": {
"isHidden": true "isHidden": true
}, },
"KestrelPort": { "ExcludeLaunchSettings": {
"isHidden": true "longName": "exclude-launch-settings",
},
"IISExpressPort": {
"isHidden": true
},
"IncludeLaunchSettings": {
"longName": "use-launch-settings",
"shortName": "" "shortName": ""
}, },
"UserSecretsId": { "UserSecretsId": {

View File

@ -47,7 +47,7 @@
] ]
}, },
{ {
"condition": "(!IncludeLaunchSettings && !WindowsAuth)", "condition": "(ExcludeLaunchSettings)",
"exclude": [ "exclude": [
"Properties/launchSettings.json" "Properties/launchSettings.json"
] ]
@ -181,11 +181,11 @@
"defaultValue": "aspnet-Company.WebApplication1-53bc9b9d-9d6a-45d4-8429-2a2761773502", "defaultValue": "aspnet-Company.WebApplication1-53bc9b9d-9d6a-45d4-8429-2a2761773502",
"description": "The ID to use for secrets (use with OrgReadAccess or Individual auth)." "description": "The ID to use for secrets (use with OrgReadAccess or Individual auth)."
}, },
"IncludeLaunchSettings": { "ExcludeLaunchSettings": {
"type": "parameter", "type": "parameter",
"datatype": "bool", "datatype": "bool",
"defaultValue": "false", "defaultValue": "false",
"description": "Whether to include launchSettings.json in the generated template." "description": "Whether to exclude launchSettings.json from the generated template."
}, },
"UseBrowserLink": { "UseBrowserLink": {
"type": "parameter", "type": "parameter",
@ -193,10 +193,28 @@
"defaultValue": "false", "defaultValue": "false",
"description": "Whether or not to include BrowserLink in the project" "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": { "HttpsPort": {
"type": "parameter", "type": "parameter",
"datatype": "integer", "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": { "HttpsPortGenerated": {
"type": "generated", "type": "generated",
@ -213,43 +231,7 @@
"sourceVariableName": "HttpsPort", "sourceVariableName": "HttpsPort",
"fallbackVariableName": "HttpsPortGenerated" "fallbackVariableName": "HttpsPortGenerated"
}, },
"replaces": "43434" "replaces": "44300"
},
"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"
}, },
"OrganizationalAuth": { "OrganizationalAuth": {
"type": "computed", "type": "computed",

View File

@ -50,20 +50,12 @@
} }
], ],
"ports": [ "ports": [
{
"name": "IISExpressPort",
"useHttps": false
},
{
"name": "KestrelPort",
"useHttps": false
},
{ {
"name": "HttpsPort", "name": "HttpsPort",
"useHttps": true "useHttps": true
} }
], ],
"excludeLaunchSettings": false,
"azureReplyUrlPortName": "HttpsPort", "azureReplyUrlPortName": "HttpsPort",
"includeLaunchSettings": true,
"minFullFrameworkVersion": "4.6.1" "minFullFrameworkVersion": "4.6.1"
} }

View File

@ -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"
}
}
}
}

View File

@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
#endif #endif
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
#if (OrganizationalAuth && OrgReadAccess) #if (OrganizationalAuth && OrgReadAccess)
@ -95,8 +96,10 @@ namespace Company.WebApplication1
else else
{ {
app.UseExceptionHandler("/Home/Error"); app.UseExceptionHandler("/Home/Error");
app.UseHsts();
} }
app.UseHttpsRedirection();
app.UseStaticFiles(); app.UseStaticFiles();
#if (OrganizationalAuth || IndividualAuth) #if (OrganizationalAuth || IndividualAuth)

View File

@ -1,6 +1,16 @@
{ {
"$schema": "http://json.schemastore.org/dotnetcli.host", "$schema": "http://json.schemastore.org/dotnetcli.host",
"symbolInfo": { "symbolInfo": {
"HttpPort": {
"isHidden": true
},
"HttpsPort": {
"isHidden": true
},
"ExcludeLaunchSettings": {
"longName": "exclude-launch-settings",
"shortName": ""
},
"TargetFrameworkOverride": { "TargetFrameworkOverride": {
"isHidden": "true", "isHidden": "true",
"longName": "target-framework-override", "longName": "target-framework-override",

View File

@ -19,7 +19,53 @@
}, },
"sourceName": "Company.WebApplication1", "sourceName": "Company.WebApplication1",
"preferNameDirectory": true, "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": { "RuntimeFrameworkVersion": {
"type": "parameter", "type": "parameter",
"replaces": "2.1.0-preview2-25624-02", "replaces": "2.1.0-preview2-25624-02",

View File

@ -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"
}
}
}
}

View File

@ -44,17 +44,14 @@
"longName": "no-restore", "longName": "no-restore",
"shortName": "" "shortName": ""
}, },
"HttpPort": {
"isHidden": true
},
"HttpsPort": { "HttpsPort": {
"isHidden": true "isHidden": true
}, },
"KestrelPort": { "ExcludeLaunchSettings": {
"isHidden": true "longName": "exclude-launch-settings",
},
"IISExpressPort": {
"isHidden": true
},
"IncludeLaunchSettings": {
"longName": "use-launch-settings",
"shortName": "" "shortName": ""
}, },
"UserSecretsId": { "UserSecretsId": {

View File

@ -33,7 +33,7 @@
] ]
}, },
{ {
"condition": "(!IncludeLaunchSettings && !WindowsAuth)", "condition": "(ExcludeLaunchSettings)",
"exclude": [ "exclude": [
"Properties/launchSettings.json" "Properties/launchSettings.json"
] ]
@ -138,16 +138,34 @@
"defaultValue": "aspnet-Company.WebApplication1-53bc9b9d-9d6a-45d4-8429-2a2761773502", "defaultValue": "aspnet-Company.WebApplication1-53bc9b9d-9d6a-45d4-8429-2a2761773502",
"description": "The ID to use for secrets (use with OrgReadAccess or Individual auth)." "description": "The ID to use for secrets (use with OrgReadAccess or Individual auth)."
}, },
"IncludeLaunchSettings": { "ExcludeLaunchSettings": {
"type": "parameter", "type": "parameter",
"datatype": "bool", "datatype": "bool",
"defaultValue": "false", "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": { "HttpsPort": {
"type": "parameter", "type": "parameter",
"datatype": "integer", "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": { "HttpsPortGenerated": {
"type": "generated", "type": "generated",
@ -164,43 +182,7 @@
"sourceVariableName": "HttpsPort", "sourceVariableName": "HttpsPort",
"fallbackVariableName": "HttpsPortGenerated" "fallbackVariableName": "HttpsPortGenerated"
}, },
"replaces": "43434" "replaces": "44300"
},
"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"
}, },
"OrganizationalAuth": { "OrganizationalAuth": {
"type": "computed", "type": "computed",

View File

@ -39,20 +39,12 @@
} }
], ],
"ports": [ "ports": [
{
"name": "IISExpressPort",
"useHttps": false
},
{
"name": "KestrelPort",
"useHttps": false
},
{ {
"name": "HttpsPort", "name": "HttpsPort",
"useHttps": true "useHttps": true
} }
], ],
"excludeLaunchSettings": false,
"azureReplyUrlPortName": "HttpsPort", "azureReplyUrlPortName": "HttpsPort",
"includeLaunchSettings": true,
"minFullFrameworkVersion": "4.6.1" "minFullFrameworkVersion": "4.6.1"
} }

View File

@ -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"
}
}
}
}

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
#if (OrganizationalAuth || IndividualB2CAuth) #if (OrganizationalAuth || IndividualB2CAuth)
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authentication.JwtBearer;
@ -49,7 +50,12 @@ namespace Company.WebApplication1
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
} }
else
{
app.UseHsts();
}
app.UseHttpsRedirection();
#if (OrganizationalAuth || IndividualAuth) #if (OrganizationalAuth || IndividualAuth)
app.UseAuthentication(); app.UseAuthentication();
#endif #endif

View File

@ -1,6 +1,16 @@
{ {
"$schema": "http://json.schemastore.org/dotnetcli.host", "$schema": "http://json.schemastore.org/dotnetcli.host",
"symbolInfo": { "symbolInfo": {
"HttpPort": {
"isHidden": true
},
"HttpsPort": {
"isHidden": true
},
"ExcludeLaunchSettings": {
"longName": "exclude-launch-settings",
"shortName": ""
},
"TargetFrameworkOverride": { "TargetFrameworkOverride": {
"isHidden": "true", "isHidden": "true",
"longName": "target-framework-override", "longName": "target-framework-override",

View File

@ -19,6 +19,52 @@
"sourceName": "Company.WebApplication1", "sourceName": "Company.WebApplication1",
"preferNameDirectory": true, "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": { "RuntimeFrameworkVersion": {
"type": "parameter", "type": "parameter",
"replaces": "2.1.0-preview2-25624-02", "replaces": "2.1.0-preview2-25624-02",

View File

@ -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"
}
}
}
}

View File

@ -19,6 +19,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkOverride)' != ''"> <ItemGroup Condition="'$(TargetFrameworkOverride)' != ''">
<PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="${MicrosoftAspNetCoreSpaServicesPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="${MicrosoftAspNetCoreSpaServicesPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="${MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="${MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion}" />

View File

@ -14,6 +14,7 @@
<GeneratedContentProperties> <GeneratedContentProperties>
MicrosoftAspNetCoreAllPackageVersion=$(MicrosoftAspNetCoreAllPackageVersion); MicrosoftAspNetCoreAllPackageVersion=$(MicrosoftAspNetCoreAllPackageVersion);
MicrosoftAspNetCorePackageVersion=$(MicrosoftAspNetCorePackageVersion); MicrosoftAspNetCorePackageVersion=$(MicrosoftAspNetCorePackageVersion);
MicrosoftAspNetCoreHttpsPolicyPackageVersion=$(MicrosoftAspNetCoreHttpsPolicyPackageVersion);
MicrosoftAspNetCoreMvcPackageVersion=$(MicrosoftAspNetCoreMvcPackageVersion); MicrosoftAspNetCoreMvcPackageVersion=$(MicrosoftAspNetCoreMvcPackageVersion);
MicrosoftAspNetCoreSpaServicesPackageVersion=$(MicrosoftAspNetCoreSpaServicesPackageVersion); MicrosoftAspNetCoreSpaServicesPackageVersion=$(MicrosoftAspNetCoreSpaServicesPackageVersion);
MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion=$(MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion); MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion=$(MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion);

View File

@ -16,6 +16,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkOverride)' != ''"> <ItemGroup Condition="'$(TargetFrameworkOverride)' != ''">
<PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="${MicrosoftAspNetCoreSpaServicesPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="${MicrosoftAspNetCoreSpaServicesPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="${MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="${MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion}" />

View File

@ -19,6 +19,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkOverride)' != ''"> <ItemGroup Condition="'$(TargetFrameworkOverride)' != ''">
<PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="${MicrosoftAspNetCoreSpaServicesPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="${MicrosoftAspNetCoreSpaServicesPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="${MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="${MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion}" />

View File

@ -12,6 +12,16 @@
"skipRestore": { "skipRestore": {
"longName": "no-restore", "longName": "no-restore",
"shortName": "" "shortName": ""
},
"HttpPort": {
"isHidden": true
},
"HttpsPort": {
"isHidden": true
},
"ExcludeLaunchSettings": {
"longName": "exclude-launch-settings",
"shortName": ""
} }
} }
} }

View File

@ -22,10 +22,64 @@
"target": "./", "target": "./",
"exclude": [ "exclude": [
".template.config/**" ".template.config/**"
],
"modifiers": [
{
"condition": "(ExcludeLaunchSettings)",
"exclude": [
"Properties/launchSettings.json"
]
}
] ]
} }
], ],
"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"
},
"TargetFrameworkOverride": { "TargetFrameworkOverride": {
"type": "parameter", "type": "parameter",
"description": "Overrides the target framework", "description": "Overrides the target framework",

View File

@ -16,5 +16,12 @@
"uiFilters": [ "uiFilters": [
"oneaspnet" "oneaspnet"
], ],
"ports": [
{
"name": "HttpsPort",
"useHttps": true
}
],
"excludeLaunchSettings": false,
"minFullFrameworkVersion": "4.6.1" "minFullFrameworkVersion": "4.6.1"
} }

View File

@ -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"
}
}
}
}

View File

@ -37,8 +37,10 @@ namespace AngularSpa
else else
{ {
app.UseExceptionHandler("/Home/Error"); app.UseExceptionHandler("/Home/Error");
app.UseHsts();
} }
app.UseHttpsRedirection();
app.UseStaticFiles(); app.UseStaticFiles();
app.UseSpaStaticFiles(); app.UseSpaStaticFiles();

View File

@ -12,6 +12,16 @@
"skipRestore": { "skipRestore": {
"longName": "no-restore", "longName": "no-restore",
"shortName": "" "shortName": ""
},
"HttpPort": {
"isHidden": true
},
"HttpsPort": {
"isHidden": true
},
"ExcludeLaunchSettings": {
"longName": "exclude-launch-settings",
"shortName": ""
} }
} }
} }

View File

@ -22,10 +22,64 @@
"target": "./", "target": "./",
"exclude": [ "exclude": [
".template.config/**" ".template.config/**"
],
"modifiers": [
{
"condition": "(ExcludeLaunchSettings)",
"exclude": [
"Properties/launchSettings.json"
]
}
] ]
} }
], ],
"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"
},
"TargetFrameworkOverride": { "TargetFrameworkOverride": {
"type": "parameter", "type": "parameter",
"description": "Overrides the target framework", "description": "Overrides the target framework",

View File

@ -16,5 +16,12 @@
"uiFilters": [ "uiFilters": [
"oneaspnet" "oneaspnet"
], ],
"ports": [
{
"name": "HttpsPort",
"useHttps": true
}
],
"excludeLaunchSettings": false,
"minFullFrameworkVersion": "4.6.1" "minFullFrameworkVersion": "4.6.1"
} }

View File

@ -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"
}
}
}
}

View File

@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer; using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -37,8 +38,10 @@ namespace ReactSpa
else else
{ {
app.UseExceptionHandler("/Home/Error"); app.UseExceptionHandler("/Home/Error");
app.UseHsts();
} }
app.UseHttpsRedirection();
app.UseStaticFiles(); app.UseStaticFiles();
app.UseSpaStaticFiles(); app.UseSpaStaticFiles();

View File

@ -9,6 +9,16 @@
"Framework": { "Framework": {
"longName": "framework" "longName": "framework"
}, },
"HttpPort": {
"isHidden": true
},
"HttpsPort": {
"isHidden": true
},
"ExcludeLaunchSettings": {
"longName": "exclude-launch-settings",
"shortName": ""
},
"skipRestore": { "skipRestore": {
"longName": "no-restore", "longName": "no-restore",
"shortName": "" "shortName": ""

View File

@ -22,10 +22,64 @@
"target": "./", "target": "./",
"exclude": [ "exclude": [
".template.config/**" ".template.config/**"
],
"modifiers": [
{
"condition": "(ExcludeLaunchSettings)",
"exclude": [
"Properties/launchSettings.json"
]
}
] ]
} }
], ],
"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"
},
"TargetFrameworkOverride": { "TargetFrameworkOverride": {
"type": "parameter", "type": "parameter",
"description": "Overrides the target framework", "description": "Overrides the target framework",

View File

@ -16,5 +16,12 @@
"uiFilters": [ "uiFilters": [
"oneaspnet" "oneaspnet"
], ],
"ports": [
{
"name": "HttpsPort",
"useHttps": true
}
],
"excludeLaunchSettings": false,
"minFullFrameworkVersion": "4.6.1" "minFullFrameworkVersion": "4.6.1"
} }

View File

@ -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"
}
}
}
}

View File

@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer; using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -37,8 +38,10 @@ namespace ReactReduxSpa
else else
{ {
app.UseExceptionHandler("/Home/Error"); app.UseExceptionHandler("/Home/Error");
app.UseHsts();
} }
app.UseHttpsRedirection();
app.UseStaticFiles(); app.UseStaticFiles();
app.UseSpaStaticFiles(); app.UseSpaStaticFiles();

View File

@ -8,6 +8,8 @@ using System.Net.Http;
using Microsoft.Extensions.CommandLineUtils; using Microsoft.Extensions.CommandLineUtils;
using Xunit; using Xunit;
using Xunit.Abstractions; using Xunit.Abstractions;
using Microsoft.AspNetCore.Certificates.Generation;
using System.Threading;
namespace Templates.Test.Helpers namespace Templates.Test.Helpers
{ {
@ -15,16 +17,28 @@ namespace Templates.Test.Helpers
{ {
private const string DefaultFramework = "netcoreapp2.0"; private const string DefaultFramework = "netcoreapp2.0";
private const string ListeningMessagePrefix = "Now listening on: "; private const string ListeningMessagePrefix = "Now listening on: ";
private static int Port = 5000 + new Random().Next(3000);
private readonly ProcessEx _process; private readonly ProcessEx _process;
private readonly Uri _listeningUri; private readonly Uri _listeningUri;
private readonly HttpClient _httpClient; private readonly HttpClient _httpClient;
private readonly ITestOutputHelper _output; private readonly ITestOutputHelper _output;
private readonly int _httpsPort;
private readonly int _httpPort;
public AspNetProcess(ITestOutputHelper output, string workingDirectory, string projectName, string targetFrameworkOverride, bool publish) public AspNetProcess(ITestOutputHelper output, string workingDirectory, string projectName, string targetFrameworkOverride, bool publish)
{ {
_output = output; _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; var framework = string.IsNullOrEmpty(targetFrameworkOverride) ? DefaultFramework : targetFrameworkOverride;
if (publish) if (publish)
@ -48,9 +62,12 @@ namespace Templates.Test.Helpers
.WaitForExit(assertSuccess: true); .WaitForExit(assertSuccess: true);
} }
_httpPort = Interlocked.Increment(ref Port);
_httpsPort = Interlocked.Increment(ref Port);
var envVars = new Dictionary<string, string> var envVars = new Dictionary<string, string>
{ {
{ "ASPNETCORE_URLS", "http://127.0.0.1:0" } { "ASPNETCORE_URLS", $"http://localhost:{_httpPort};https://localhost:{_httpsPort}" },
{ "ASPNETCORE_HTTPS_PORT", $"{_httpsPort}" }
}; };
if (!publish) if (!publish)

View File

@ -17,6 +17,7 @@ namespace Templates.Test
private static object DotNetNewLock = new object(); private static object DotNetNewLock = new object();
protected string ProjectName { get; set; } protected string ProjectName { get; set; }
protected string ProjectGuid { get; set; }
protected string TemplateOutputDir { get; private set; } protected string TemplateOutputDir { get; private set; }
protected ITestOutputHelper Output { get; private set; } protected ITestOutputHelper Output { get; private set; }
@ -25,7 +26,8 @@ namespace Templates.Test
TemplatePackageInstaller.EnsureTemplatePackagesWereReinstalled(output); TemplatePackageInstaller.EnsureTemplatePackagesWereReinstalled(output);
Output = output; Output = output;
ProjectName = Guid.NewGuid().ToString().Replace("-", ""); ProjectGuid = Guid.NewGuid().ToString("N");
ProjectName = $"AspNet.Template.{ProjectGuid}";
var assemblyPath = GetType().GetTypeInfo().Assembly.CodeBase; var assemblyPath = GetType().GetTypeInfo().Assembly.CodeBase;
var assemblyUri = new Uri(assemblyPath, UriKind.Absolute); var assemblyUri = new Uri(assemblyPath, UriKind.Absolute);

View File

@ -1,17 +1,24 @@
using OpenQA.Selenium; using System;
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.Firefox;
using System;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using OpenQA.Selenium;
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.Firefox;
namespace Templates.Test.Helpers namespace Templates.Test.Helpers
{ {
public static class WebDriverFactory 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 public static bool HostSupportsBrowserAutomation
=> IsAppVeyor || OSSupportsEdge(); => string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("ASPNETCORE_BROWSER_AUTOMATION_DISABLED")) &&
(IsAppVeyor || OSSupportsEdge());
private static bool IsAppVeyor private static bool IsAppVeyor
=> Environment.GetEnvironmentVariables().Contains("APPVEYOR"); => Environment.GetEnvironmentVariables().Contains("APPVEYOR");
@ -21,16 +28,24 @@ namespace Templates.Test.Helpers
// Where possible, it's preferable to use Edge because it's // Where possible, it's preferable to use Edge because it's
// far faster to automate than Chrome/Firefox. But on AppVeyor // far faster to automate than Chrome/Firefox. But on AppVeyor
// only Firefox is available. // only Firefox is available.
var result = IsAppVeyor ? CreateFirefoxDriver() : CreateEdgeDriver(); var result = (IsAppVeyor || UseFirefox()) ? CreateFirefoxDriver() : CreateEdgeDriver();
result.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1); result.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(DefaultMaxWaitTimeInSeconds);
return result; return result;
bool UseFirefox() => !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("ASPNETCORE_BROWSER_AUTOMATION_FIREFOX"));
} }
private static IWebDriver CreateEdgeDriver() private static IWebDriver CreateEdgeDriver()
=> new EdgeDriver(EdgeDriverService.CreateDefaultService(BinDir)); => new EdgeDriver(EdgeDriverService.CreateDefaultService(BinDir));
private static IWebDriver CreateFirefoxDriver() 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 private static string BinDir
=> Path.GetDirectoryName(typeof(WebDriverFactory).Assembly.Location); => Path.GetDirectoryName(typeof(WebDriverFactory).Assembly.Location);
@ -45,7 +60,7 @@ namespace Templates.Test.Helpers
private static bool OSSupportsEdge() private static bool OSSupportsEdge()
{ {
var windowsVersion = GetWindowsVersion(); var windowsVersion = GetWindowsVersion();
return (windowsVersion >= 10 && windowsVersion < 2000) return (windowsVersion >= DefaultMaxWaitTimeInSeconds && windowsVersion < 2000)
|| (windowsVersion >= 2016); || (windowsVersion >= 2016);
} }
} }

View File

@ -24,7 +24,7 @@ namespace Templates.Test
[InlineData(null)] [InlineData(null)]
[InlineData("F#")] [InlineData("F#")]
public void MvcTemplate_NoAuth_Works_NetCore(string languageOverride) 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) private void MvcTemplate_NoAuthImpl(string targetFrameworkOverride, string languageOverride)
{ {

View File

@ -62,7 +62,7 @@ namespace Templates.Test.SpaTemplateTest
private void TestBasicNavigation(IWebDriver browser) private void TestBasicNavigation(IWebDriver browser)
{ {
// <title> element gets project ID injected into it during template execution // <title> 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 // Initially displays the home page
Assert.Equal("Hello, world!", browser.GetText("h1")); Assert.Equal("Hello, world!", browser.GetText("h1"));

View File

@ -2,10 +2,12 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
<DefineConstants>$(DefineConstants);XPLAT</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Internal.AspNetCore.Sdk" Version="$(InternalAspNetCoreSdkPackageVersion)" /> <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.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.CommandLineUtils.Sources" Version="$(MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion)" /> <PackageReference Include="Microsoft.Extensions.CommandLineUtils.Sources" Version="$(MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Process.Sources" Version="$(MicrosoftExtensionsProcessSourcesPackageVersion)" PrivateAssets="All" /> <PackageReference Include="Microsoft.Extensions.Process.Sources" Version="$(MicrosoftExtensionsProcessSourcesPackageVersion)" PrivateAssets="All" />