Add no-https option for all templates (#413)

Addresses #322
This commit is contained in:
Jass Bagga 2018-03-29 13:59:47 -07:00 committed by GitHub
parent aca30fe8a2
commit cb7942abe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
53 changed files with 266 additions and 41 deletions

View File

@ -30,7 +30,7 @@
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="${MicrosoftAspNetCoreAuthenticationCookiesPackageVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="${MicrosoftAspNetCoreAuthenticationCookiesPackageVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" />
<PackageReference Include="Microsoft.AspNetCore.CookiePolicy" Version="${MicrosoftAspNetCoreCookiePolicyPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.CookiePolicy" Version="${MicrosoftAspNetCoreCookiePolicyPackageVersion}" />
<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.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" Condition="'$(RequiresHttps)' == 'True'"/>
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="${MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" /> <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="${MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" />
<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}" />

View File

@ -22,7 +22,7 @@
<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" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="${MicrosoftAspNetCoreStaticFilesPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="${MicrosoftAspNetCoreStaticFilesPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" Condition="'$(NoHttps)' != 'True'"/>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -21,7 +21,7 @@
<PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.AzureAD.UI" Version="${MicrosoftAspNetCoreAuthenticationAzureADUIPackageVersion}" Condition="'$(OrganizationalAuth)' == 'True'" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.AzureAD.UI" Version="${MicrosoftAspNetCoreAuthenticationAzureADUIPackageVersion}" Condition="'$(OrganizationalAuth)' == 'True'" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.AzureADB2C.UI" Version="${MicrosoftAspNetCoreAuthenticationAzureADB2CUIPackageVersion}" Condition="'$(IndividualB2CAuth)' == 'True'" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.AzureADB2C.UI" Version="${MicrosoftAspNetCoreAuthenticationAzureADB2CUIPackageVersion}" Condition="'$(IndividualB2CAuth)' == 'True'" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" Condition="'$(RequiresHttps)' == 'True'" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" />
</ItemGroup> </ItemGroup>

View File

@ -17,7 +17,7 @@
<ItemGroup Condition="'$(TargetFrameworkOverride)' != ''"> <ItemGroup Condition="'$(TargetFrameworkOverride)' != ''">
<PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore" Version="${MicrosoftAspNetCorePackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="${MicrosoftAspNetCoreMvcPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" /> <PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" Condition="'$(NoHttps)' != 'True'" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -22,6 +22,10 @@
"ExcludeLaunchSettings": { "ExcludeLaunchSettings": {
"longName": "exclude-launch-settings", "longName": "exclude-launch-settings",
"shortName": "" "shortName": ""
},
"NoHttps": {
"longName": "no-https",
"shortName": ""
} }
}, },
"usageExamples": [ "usageExamples": [

View File

@ -68,7 +68,7 @@
"HttpsPort": { "HttpsPort": {
"type": "parameter", "type": "parameter",
"datatype": "integer", "datatype": "integer",
"description": "Port number to use for the HTTPS endpoint in launchSettings.json." "description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used)."
}, },
"HttpsPortGenerated": { "HttpsPortGenerated": {
"type": "generated", "type": "generated",
@ -120,6 +120,12 @@
"datatype": "bool", "datatype": "bool",
"description": "If specified, skips the automatic restore of the project on create.", "description": "If specified, skips the automatic restore of the project on create.",
"defaultValue": "false" "defaultValue": "false"
},
"NoHttps": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Whether to turn off HTTPS. This option only applies if IndividualAuth or OrganizationalAuth are not being used."
} }
}, },
"primaryOutputs": [ "primaryOutputs": [

View File

@ -27,5 +27,6 @@
} }
], ],
"excludeLaunchSettings": false, "excludeLaunchSettings": false,
"minFullFrameworkVersion": "4.6.1" "minFullFrameworkVersion": "4.6.1",
"disableHttpsSymbol": "NoHttps"
} }

View File

@ -18,7 +18,11 @@
"Company.WebApplication1": { "Company.WebApplication1": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
//#if(NoHttps)
"applicationUrl": "http://localhost:5000",
//#else
"applicationUrl": "https://localhost:5001;http://localhost:5000", "applicationUrl": "https://localhost:5001;http://localhost:5000",
//#endif
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }

View File

@ -22,6 +22,10 @@
"ExcludeLaunchSettings": { "ExcludeLaunchSettings": {
"longName": "exclude-launch-settings", "longName": "exclude-launch-settings",
"shortName": "" "shortName": ""
},
"NoHttps": {
"longName": "no-https",
"shortName": ""
} }
}, },
"usageExamples": [ "usageExamples": [

View File

@ -64,7 +64,7 @@
"HttpsPort": { "HttpsPort": {
"type": "parameter", "type": "parameter",
"datatype": "integer", "datatype": "integer",
"description": "Port number to use for the HTTPS endpoint in launchSettings.json." "description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used)."
}, },
"HttpsPortGenerated": { "HttpsPortGenerated": {
"type": "generated", "type": "generated",
@ -116,6 +116,12 @@
"datatype": "bool", "datatype": "bool",
"description": "If specified, skips the automatic restore of the project on create.", "description": "If specified, skips the automatic restore of the project on create.",
"defaultValue": "false" "defaultValue": "false"
},
"NoHttps": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Whether to turn off HTTPS. This option only applies if IndividualAuth or OrganizationalAuth are not being used."
} }
}, },
"primaryOutputs": [ "primaryOutputs": [

View File

@ -25,5 +25,6 @@
"useHttps": true "useHttps": true
} }
], ],
"minFullFrameworkVersion": "4.6.1" "minFullFrameworkVersion": "4.6.1",
"disableHttpsSymbol": "NoHttps"
} }

View File

@ -18,7 +18,11 @@
"Company.WebApplication1": { "Company.WebApplication1": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
//#if(NoHttps)
"applicationUrl": "http://localhost:5000",
//#else
"applicationUrl": "https://localhost:5001;http://localhost:5000", "applicationUrl": "https://localhost:5001;http://localhost:5000",
//#endif
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }

View File

@ -307,6 +307,12 @@
"defaultValue": "false", "defaultValue": "false",
"description": "Whether to turn off HTTPS. This option only applies if IndividualAuth or OrganizationalAuth are not being used." "description": "Whether to turn off HTTPS. This option only applies if IndividualAuth or OrganizationalAuth are not being used."
}, },
"NoHttps": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Whether to turn off HTTPS. This option only applies if IndividualAuth or OrganizationalAuth are not being used."
},
"UseLocalDB": { "UseLocalDB": {
"type": "parameter", "type": "parameter",
"datatype": "bool", "datatype": "bool",

View File

@ -72,6 +72,10 @@
"UseBrowserLink": { "UseBrowserLink": {
"longName": "use-browserlink", "longName": "use-browserlink",
"shortName": "" "shortName": ""
},
"NoHttps": {
"longName": "no-https",
"shortName": ""
} }
}, },
"usageExamples": [ "usageExamples": [

View File

@ -239,7 +239,7 @@
"HttpsPort": { "HttpsPort": {
"type": "parameter", "type": "parameter",
"datatype": "integer", "datatype": "integer",
"description": "Port number to use for the HTTPS endpoint in launchSettings.json." "description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used)."
}, },
"HttpsPortGenerated": { "HttpsPortGenerated": {
"type": "generated", "type": "generated",
@ -292,7 +292,13 @@
}, },
"RequiresHttps": { "RequiresHttps": {
"type": "computed", "type": "computed",
"value": "(OrganizationalAuth || IndividualAuth)" "value": "(OrganizationalAuth || IndividualAuth || !NoHttps)"
},
"NoHttps": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Whether to turn off HTTPS. This option only applies if IndividualAuth or OrganizationalAuth are not being used."
}, },
"UseLocalDB": { "UseLocalDB": {
"type": "parameter", "type": "parameter",

View File

@ -22,7 +22,8 @@
"supportedAuthentications": [ "supportedAuthentications": [
{ {
"auth": "None", "auth": "None",
"authenticationType": "NoAuth" "authenticationType": "NoAuth",
"allowUnsecured": true
}, },
{ {
"auth": "Individual", "auth": "Individual",
@ -61,5 +62,6 @@
], ],
"excludeLaunchSettings": false, "excludeLaunchSettings": false,
"azureReplyUrlPortName": "HttpsPort", "azureReplyUrlPortName": "HttpsPort",
"minFullFrameworkVersion": "4.6.1" "minFullFrameworkVersion": "4.6.1",
"disableHttpsSymbol": "NoHttps"
} }

View File

@ -18,7 +18,11 @@
"Company.WebApplication1": { "Company.WebApplication1": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
//#if(RequiresHttps)
"applicationUrl": "https://localhost:5001;http://localhost:5000", "applicationUrl": "https://localhost:5001;http://localhost:5000",
//#else
"applicationUrl": "http://localhost:5000",
//#endif
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }

View File

@ -21,7 +21,9 @@ using Microsoft.AspNetCore.Identity;
#endif #endif
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
#if (RequiresHttps)
using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.AspNetCore.HttpsPolicy;
#endif
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
#if (OrganizationalAuth) #if (OrganizationalAuth)
using Microsoft.AspNetCore.Mvc.Authorization; using Microsoft.AspNetCore.Mvc.Authorization;
@ -143,10 +145,15 @@ namespace Company.WebApplication1
else else
{ {
app.UseExceptionHandler("/Home/Error"); app.UseExceptionHandler("/Home/Error");
#if (RequiresHttps)
app.UseHsts(); app.UseHsts();
} }
app.UseHttpsRedirection(); app.UseHttpsRedirection();
#else
}
#endif
app.UseStaticFiles(); app.UseStaticFiles();
app.UseCookiePolicy(); app.UseCookiePolicy();

View File

@ -22,6 +22,10 @@
"skipRestore": { "skipRestore": {
"longName": "no-restore", "longName": "no-restore",
"shortName": "" "shortName": ""
},
"NoHttps": {
"longName": "no-https",
"shortName": ""
} }
}, },
"usageExamples": [ "usageExamples": [

View File

@ -74,7 +74,7 @@
"HttpsPort": { "HttpsPort": {
"type": "parameter", "type": "parameter",
"datatype": "integer", "datatype": "integer",
"description": "Port number to use for the HTTPS endpoint in launchSettings.json." "description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used)."
}, },
"HttpsPortGenerated": { "HttpsPortGenerated": {
"type": "generated", "type": "generated",
@ -126,6 +126,12 @@
"datatype": "bool", "datatype": "bool",
"description": "If specified, skips the automatic restore of the project on create.", "description": "If specified, skips the automatic restore of the project on create.",
"defaultValue": "false" "defaultValue": "false"
},
"NoHttps": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Whether to turn off HTTPS. This option only applies if IndividualAuth or OrganizationalAuth are not being used."
} }
}, },
"primaryOutputs": [ "primaryOutputs": [

View File

@ -18,7 +18,11 @@
"Company.WebApplication1": { "Company.WebApplication1": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
//#if(NoHttps)
"applicationUrl": "http://localhost:5000",
//#else
"applicationUrl": "https://localhost:5001;http://localhost:5000", "applicationUrl": "https://localhost:5001;http://localhost:5000",
//#endif
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }

View File

@ -6,7 +6,9 @@ open System.Linq
open System.Threading.Tasks open System.Threading.Tasks
open Microsoft.AspNetCore.Builder open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Hosting open Microsoft.AspNetCore.Hosting
open Microsoft.AspNetCore.HttpsPolicy #if (!NoHttps)
open Microsoft.AspNetCore.HttpsPolicy;
#endif
open Microsoft.AspNetCore.Mvc open Microsoft.AspNetCore.Mvc
open Microsoft.Extensions.Configuration open Microsoft.Extensions.Configuration
open Microsoft.Extensions.DependencyInjection open Microsoft.Extensions.DependencyInjection
@ -28,9 +30,13 @@ type Startup private () =
app.UseDeveloperExceptionPage() |> ignore app.UseDeveloperExceptionPage() |> ignore
else else
app.UseExceptionHandler("/Home/Error") |> ignore app.UseExceptionHandler("/Home/Error") |> ignore
#if (!NoHttps)
app.UseHsts() |> ignore app.UseHsts() |> ignore
app.UseHttpsRedirection() |> ignore app.UseHttpsRedirection() |> ignore
#else
#endif
app.UseStaticFiles() |> ignore app.UseStaticFiles() |> ignore
app.UseMvc(fun routes -> app.UseMvc(fun routes ->

View File

@ -56,6 +56,10 @@
}, },
"UserSecretsId": { "UserSecretsId": {
"isHidden": true "isHidden": true
},
"NoHttps": {
"longName": "no-https",
"shortName": ""
} }
}, },
"usageExamples": [ "usageExamples": [

View File

@ -151,7 +151,7 @@
"HttpsPort": { "HttpsPort": {
"type": "parameter", "type": "parameter",
"datatype": "integer", "datatype": "integer",
"description": "Port number to use for the HTTPS endpoint in launchSettings.json." "description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used)."
}, },
"HttpsPortGenerated": { "HttpsPortGenerated": {
"type": "generated", "type": "generated",
@ -196,7 +196,13 @@
}, },
"RequiresHttps": { "RequiresHttps": {
"type": "computed", "type": "computed",
"value": "(OrganizationalAuth || IndividualAuth)" "value": "(OrganizationalAuth || IndividualAuth || !NoHttps)"
},
"NoHttps": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Whether to turn off HTTPS. This option only applies if IndividualAuth or OrganizationalAuth are not being used."
}, },
"UseLocalDB": { "UseLocalDB": {
"type": "parameter", "type": "parameter",

View File

@ -21,7 +21,8 @@
"supportedAuthentications": [ "supportedAuthentications": [
{ {
"auth": "None", "auth": "None",
"authenticationType": "NoAuth" "authenticationType": "NoAuth",
"allowUnsecured": true
}, },
{ {
"auth": "Individual", "auth": "Individual",
@ -50,5 +51,6 @@
], ],
"excludeLaunchSettings": false, "excludeLaunchSettings": false,
"azureReplyUrlPortName": "HttpsPort", "azureReplyUrlPortName": "HttpsPort",
"minFullFrameworkVersion": "4.6.1" "minFullFrameworkVersion": "4.6.1",
"disableHttpsSymbol": "NoHttps"
} }

View File

@ -18,7 +18,11 @@
"Company.WebApplication1": { "Company.WebApplication1": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
//#if(RequiresHttps)
"applicationUrl": "https://localhost:5001;http://localhost:5000", "applicationUrl": "https://localhost:5001;http://localhost:5000",
//#else
"applicationUrl": "http://localhost:5000",
//#endif
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }

View File

@ -4,7 +4,9 @@ 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;
#if (RequiresHttps)
using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.AspNetCore.HttpsPolicy;
#endif
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
#if (OrganizationalAuth || IndividualB2CAuth) #if (OrganizationalAuth || IndividualB2CAuth)
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
@ -51,11 +53,16 @@ namespace Company.WebApplication1
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
} }
#if (RequiresHttps)
else else
{ {
app.UseHsts(); app.UseHsts();
} }
app.UseHttpsRedirection();
#else
#endif
app.UseHttpsRedirection(); app.UseHttpsRedirection();
#if (OrganizationalAuth || IndividualAuth) #if (OrganizationalAuth || IndividualAuth)
app.UseAuthentication(); app.UseAuthentication();

View File

@ -22,6 +22,10 @@
"skipRestore": { "skipRestore": {
"longName": "no-restore", "longName": "no-restore",
"shortName": "" "shortName": ""
},
"NoHttps": {
"longName": "no-https",
"shortName": ""
} }
}, },
"usageExamples": [ "usageExamples": [

View File

@ -64,7 +64,7 @@
"HttpsPort": { "HttpsPort": {
"type": "parameter", "type": "parameter",
"datatype": "integer", "datatype": "integer",
"description": "Port number to use for the HTTPS endpoint in launchSettings.json." "description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used)."
}, },
"HttpsPortGenerated": { "HttpsPortGenerated": {
"type": "generated", "type": "generated",
@ -116,6 +116,12 @@
"datatype": "bool", "datatype": "bool",
"description": "If specified, skips the automatic restore of the project on create.", "description": "If specified, skips the automatic restore of the project on create.",
"defaultValue": "false" "defaultValue": "false"
},
"NoHttps": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Whether to turn off HTTPS. This option only applies if IndividualAuth or OrganizationalAuth are not being used."
} }
}, },
"primaryOutputs": [ "primaryOutputs": [

View File

@ -27,5 +27,6 @@
} }
], ],
"azureReplyUrlPortName": "HttpsPort", "azureReplyUrlPortName": "HttpsPort",
"minFullFrameworkVersion": "4.6.1" "minFullFrameworkVersion": "4.6.1",
"disableHttpsSymbol": "NoHttps"
} }

View File

@ -18,7 +18,11 @@
"Company.WebApplication1": { "Company.WebApplication1": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
//#if(NoHttps)
"applicationUrl": "http://localhost:5000",
//#else
"applicationUrl": "https://localhost:5001;http://localhost:5000", "applicationUrl": "https://localhost:5001;http://localhost:5000",
//#endif
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }

View File

@ -6,7 +6,9 @@ open System.Linq
open System.Threading.Tasks open System.Threading.Tasks
open Microsoft.AspNetCore.Builder open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Hosting open Microsoft.AspNetCore.Hosting
open Microsoft.AspNetCore.HttpsPolicy #if (!NoHttps)
open Microsoft.AspNetCore.HttpsPolicy;
#endif
open Microsoft.AspNetCore.Mvc open Microsoft.AspNetCore.Mvc
open Microsoft.Extensions.Configuration open Microsoft.Extensions.Configuration
open Microsoft.Extensions.DependencyInjection open Microsoft.Extensions.DependencyInjection
@ -25,10 +27,14 @@ type Startup private () =
member this.Configure(app: IApplicationBuilder, env: IHostingEnvironment) = member this.Configure(app: IApplicationBuilder, env: IHostingEnvironment) =
if (env.IsDevelopment()) then if (env.IsDevelopment()) then
app.UseDeveloperExceptionPage() |> ignore app.UseDeveloperExceptionPage() |> ignore
#if (!NoHttps)
else else
app.UseHsts() |> ignore app.UseHsts() |> ignore
app.UseHttpsRedirection() |> ignore app.UseHttpsRedirection() |> ignore
#else
#endif
app.UseMvc() |> ignore app.UseMvc() |> ignore
member val Configuration : IConfiguration = null with get, set member val Configuration : IConfiguration = null with get, set

View File

@ -19,7 +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.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" Condition="'$(NoHttps)' != 'True'"/>
<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

@ -16,7 +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.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" Condition="'$(NoHttps)' != 'True'"/>
<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

@ -16,7 +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.HttpsPolicy" Version="${MicrosoftAspNetCoreHttpsPolicyPackageVersion}" Condition="'$(NoHttps)' != 'True'"/>
<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

@ -22,6 +22,10 @@
"ExcludeLaunchSettings": { "ExcludeLaunchSettings": {
"longName": "exclude-launch-settings", "longName": "exclude-launch-settings",
"shortName": "" "shortName": ""
},
"NoHttps": {
"longName": "no-https",
"shortName": ""
} }
} }
} }

View File

@ -67,7 +67,7 @@
"HttpsPort": { "HttpsPort": {
"type": "parameter", "type": "parameter",
"datatype": "integer", "datatype": "integer",
"description": "Port number to use for the HTTPS endpoint in launchSettings.json." "description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used)."
}, },
"HttpsPortGenerated": { "HttpsPortGenerated": {
"type": "generated", "type": "generated",
@ -115,6 +115,12 @@
"datatype": "bool", "datatype": "bool",
"description": "If specified, skips the automatic restore of the project on create.", "description": "If specified, skips the automatic restore of the project on create.",
"defaultValue": "false" "defaultValue": "false"
},
"NoHttps": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Whether to turn off HTTPS. This option only applies if IndividualAuth or OrganizationalAuth are not being used."
} }
}, },
"tags": { "tags": {

View File

@ -27,5 +27,6 @@
} }
], ],
"excludeLaunchSettings": false, "excludeLaunchSettings": false,
"minFullFrameworkVersion": "4.6.1" "minFullFrameworkVersion": "4.6.1",
"disableHttpsSymbol": "NoHttps"
} }

View File

@ -18,7 +18,11 @@
"Company.WebApplication1": { "Company.WebApplication1": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
//#if(NoHttps)
"applicationUrl": "http://localhost:5000",
//#else
"applicationUrl": "https://localhost:5001;http://localhost:5000", "applicationUrl": "https://localhost:5001;http://localhost:5000",
//#endif
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }

View File

@ -1,5 +1,8 @@
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
#if (!NoHttps)
using Microsoft.AspNetCore.HttpsPolicy;
#endif
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SpaServices.AngularCli; using Microsoft.AspNetCore.SpaServices.AngularCli;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
@ -38,10 +41,15 @@ namespace Company.WebApplication1
else else
{ {
app.UseExceptionHandler("/Home/Error"); app.UseExceptionHandler("/Home/Error");
#if (!NoHttps)
app.UseHsts(); app.UseHsts();
} }
app.UseHttpsRedirection(); app.UseHttpsRedirection();
#else
}
#endif
app.UseStaticFiles(); app.UseStaticFiles();
app.UseSpaStaticFiles(); app.UseSpaStaticFiles();

View File

@ -22,6 +22,10 @@
"ExcludeLaunchSettings": { "ExcludeLaunchSettings": {
"longName": "exclude-launch-settings", "longName": "exclude-launch-settings",
"shortName": "" "shortName": ""
},
"NoHttps": {
"longName": "no-https",
"shortName": ""
} }
} }
} }

View File

@ -67,7 +67,7 @@
"HttpsPort": { "HttpsPort": {
"type": "parameter", "type": "parameter",
"datatype": "integer", "datatype": "integer",
"description": "Port number to use for the HTTPS endpoint in launchSettings.json." "description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used)."
}, },
"HttpsPortGenerated": { "HttpsPortGenerated": {
"type": "generated", "type": "generated",
@ -115,6 +115,12 @@
"datatype": "bool", "datatype": "bool",
"description": "If specified, skips the automatic restore of the project on create.", "description": "If specified, skips the automatic restore of the project on create.",
"defaultValue": "false" "defaultValue": "false"
},
"NoHttps": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Whether to turn off HTTPS. This option only applies if IndividualAuth or OrganizationalAuth are not being used."
} }
}, },
"tags": { "tags": {

View File

@ -27,5 +27,6 @@
} }
], ],
"excludeLaunchSettings": false, "excludeLaunchSettings": false,
"minFullFrameworkVersion": "4.6.1" "minFullFrameworkVersion": "4.6.1",
"disableHttpsSymbol": "NoHttps"
} }

View File

@ -18,7 +18,11 @@
"Company.WebApplication1": { "Company.WebApplication1": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
//#if(NoHttps)
"applicationUrl": "http://localhost:5000",
//#else
"applicationUrl": "https://localhost:5001;http://localhost:5000", "applicationUrl": "https://localhost:5001;http://localhost:5000",
//#endif
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }

View File

@ -1,6 +1,8 @@
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
#if (!NoHttps)
using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.AspNetCore.HttpsPolicy;
#endif
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer; using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
@ -39,10 +41,15 @@ namespace Company.WebApplication1
else else
{ {
app.UseExceptionHandler("/Home/Error"); app.UseExceptionHandler("/Home/Error");
#if (!NoHttps)
app.UseHsts(); app.UseHsts();
} }
app.UseHttpsRedirection(); app.UseHttpsRedirection();
#else
}
#endif
app.UseStaticFiles(); app.UseStaticFiles();
app.UseSpaStaticFiles(); app.UseSpaStaticFiles();

View File

@ -22,6 +22,10 @@
"skipRestore": { "skipRestore": {
"longName": "no-restore", "longName": "no-restore",
"shortName": "" "shortName": ""
},
"NoHttps": {
"longName": "no-https",
"shortName": ""
} }
} }
} }

View File

@ -67,7 +67,7 @@
"HttpsPort": { "HttpsPort": {
"type": "parameter", "type": "parameter",
"datatype": "integer", "datatype": "integer",
"description": "Port number to use for the HTTPS endpoint in launchSettings.json." "description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used)."
}, },
"HttpsPortGenerated": { "HttpsPortGenerated": {
"type": "generated", "type": "generated",
@ -115,6 +115,12 @@
"datatype": "bool", "datatype": "bool",
"description": "If specified, skips the automatic restore of the project on create.", "description": "If specified, skips the automatic restore of the project on create.",
"defaultValue": "false" "defaultValue": "false"
},
"NoHttps": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Whether to turn off HTTPS. This option only applies if IndividualAuth or OrganizationalAuth are not being used."
} }
}, },
"tags": { "tags": {

View File

@ -27,5 +27,6 @@
} }
], ],
"excludeLaunchSettings": false, "excludeLaunchSettings": false,
"minFullFrameworkVersion": "4.6.1" "minFullFrameworkVersion": "4.6.1",
"disableHttpsSymbol": "NoHttps"
} }

View File

@ -18,7 +18,11 @@
"Company.WebApplication1": { "Company.WebApplication1": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
//#if(NoHttps)
"applicationUrl": "http://localhost:5000",
//#else
"applicationUrl": "https://localhost:5001;http://localhost:5000", "applicationUrl": "https://localhost:5001;http://localhost:5000",
//#endif
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }

View File

@ -1,6 +1,8 @@
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
#if (!NoHttps)
using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.AspNetCore.HttpsPolicy;
#endif
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer; using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
@ -39,10 +41,15 @@ namespace Company.WebApplication1
else else
{ {
app.UseExceptionHandler("/Home/Error"); app.UseExceptionHandler("/Home/Error");
#if (!NoHttps)
app.UseHsts(); app.UseHsts();
} }
app.UseHttpsRedirection(); app.UseHttpsRedirection();
#else
}
#endif
app.UseStaticFiles(); app.UseStaticFiles();
app.UseSpaStaticFiles(); app.UseSpaStaticFiles();

View File

@ -23,6 +23,16 @@ namespace Templates.Test
public void MvcTemplate_NoAuth_Works_NetFramework_ForFSharpTemplate() public void MvcTemplate_NoAuth_Works_NetFramework_ForFSharpTemplate()
=> MvcTemplate_NoAuthImpl("net461", languageOverride: "F#"); => MvcTemplate_NoAuthImpl("net461", languageOverride: "F#");
[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)]
public void MvcTemplate_NoAuth_NoHttps_Works_NetFramework_ForDefaultTemplate()
=> MvcTemplate_NoAuthImpl("net471", languageOverride: default, true);
[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)]
public void MvcTemplate_NoAuth_NoHttps_Works_NetFramework_ForFSharpTemplate()
=> MvcTemplate_NoAuthImpl("net471", languageOverride: "F#", true);
[Fact] [Fact]
public void MvcTemplate_NoAuth_Works_NetCore_ForDefaultTemplate() public void MvcTemplate_NoAuth_Works_NetCore_ForDefaultTemplate()
=> MvcTemplate_NoAuthImpl(null, languageOverride: default); => MvcTemplate_NoAuthImpl(null, languageOverride: default);
@ -31,9 +41,9 @@ namespace Templates.Test
public void MvcTemplate_NoAuth_Works_NetCore_ForFSharpTemplate() public void MvcTemplate_NoAuth_Works_NetCore_ForFSharpTemplate()
=> MvcTemplate_NoAuthImpl(null, languageOverride: "F#"); => MvcTemplate_NoAuthImpl(null, languageOverride: "F#");
private void MvcTemplate_NoAuthImpl(string targetFrameworkOverride, string languageOverride) private void MvcTemplate_NoAuthImpl(string targetFrameworkOverride, string languageOverride, bool noHttps = false)
{ {
RunDotNetNew("mvc", targetFrameworkOverride, language: languageOverride); RunDotNetNew("mvc", targetFrameworkOverride, language: languageOverride, noHttps: noHttps);
AssertDirectoryExists("Areas", false); AssertDirectoryExists("Areas", false);
AssertDirectoryExists("Extensions", false); AssertDirectoryExists("Extensions", false);
@ -48,6 +58,18 @@ namespace Templates.Test
Assert.DoesNotContain("Microsoft.EntityFrameworkCore.Tools.DotNet", projectFileContents); Assert.DoesNotContain("Microsoft.EntityFrameworkCore.Tools.DotNet", projectFileContents);
Assert.DoesNotContain("Microsoft.Extensions.SecretManager.Tools", projectFileContents); Assert.DoesNotContain("Microsoft.Extensions.SecretManager.Tools", projectFileContents);
if (targetFrameworkOverride != null)
{
if (noHttps)
{
Assert.DoesNotContain("Microsoft.AspNetCore.HttpsPolicy", projectFileContents);
}
else
{
Assert.Contains("Microsoft.AspNetCore.HttpsPolicy", projectFileContents);
}
}
foreach (var publish in new[] { false, true }) foreach (var publish in new[] { false, true })
{ {
using (var aspNetProcess = StartAspNetProcess(targetFrameworkOverride, publish)) using (var aspNetProcess = StartAspNetProcess(targetFrameworkOverride, publish))
@ -60,11 +82,15 @@ namespace Templates.Test
} }
[ConditionalFact(Skip = "https://github.com/aspnet/templating/issues/378")] [ConditionalFact(Skip = "https://github.com/aspnet/templating/issues/378")]
[OSSkipCondition(OperatingSystems.Linux)] [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public void MvcTemplate_IndividualAuth_Works_NetFramework() public void MvcTemplate_IndividualAuth_Works_NetFramework()
=> MvcTemplate_IndividualAuthImpl("net461"); => MvcTemplate_IndividualAuthImpl("net461");
[ConditionalFact(Skip = "https://github.com/aspnet/templating/issues/378")]
[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)]
public void MvcTemplate_WithIndividualAuth_NoHttpsSetToTrue_UsesHttps_NetFramework()
=> MvcTemplate_IndividualAuthImpl("net471", false, true);
[Fact(Skip = "https://github.com/aspnet/templating/issues/378")] [Fact(Skip = "https://github.com/aspnet/templating/issues/378")]
public void MvcTemplate_IndividualAuth_Works_NetCore() public void MvcTemplate_IndividualAuth_Works_NetCore()
=> MvcTemplate_IndividualAuthImpl(null); => MvcTemplate_IndividualAuthImpl(null);
@ -73,7 +99,7 @@ namespace Templates.Test
public void MvcTemplate_IndividualAuth_UsingLocalDB_Works_NetCore() public void MvcTemplate_IndividualAuth_UsingLocalDB_Works_NetCore()
=> MvcTemplate_IndividualAuthImpl(null, true); => MvcTemplate_IndividualAuthImpl(null, true);
private void MvcTemplate_IndividualAuthImpl(string targetFrameworkOverride, bool useLocalDB = false) private void MvcTemplate_IndividualAuthImpl(string targetFrameworkOverride, bool useLocalDB = false, bool noHttps = false)
{ {
RunDotNetNew("mvc", targetFrameworkOverride, auth: "Individual", useLocalDB: useLocalDB); RunDotNetNew("mvc", targetFrameworkOverride, auth: "Individual", useLocalDB: useLocalDB);
@ -88,6 +114,11 @@ namespace Templates.Test
} }
Assert.Contains("Microsoft.VisualStudio.Web.CodeGeneration.Design", projectFileContents); Assert.Contains("Microsoft.VisualStudio.Web.CodeGeneration.Design", projectFileContents);
if (targetFrameworkOverride != null)
{
Assert.Contains("Microsoft.AspNetCore.HttpsPolicy", projectFileContents);
}
RunDotNetEfCreateMigration("mvc"); RunDotNetEfCreateMigration("mvc");
AssertEmptyMigration("mvc"); AssertEmptyMigration("mvc");

View File

@ -11,13 +11,17 @@ namespace Templates.Test.SpaTemplateTest
} }
[ConditionalFact] [ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux)] [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)]
[OSSkipCondition(OperatingSystems.MacOSX)]
// Just use 'angular' as representative for .NET 4.6.1 coverage, as // Just use 'angular' as representative for .NET 4.6.1 coverage, as
// the client-side code isn't affected by the .NET runtime choice // the client-side code isn't affected by the .NET runtime choice
public void AngularTemplate_Works_NetFramework() public void AngularTemplate_Works_NetFramework()
=> SpaTemplateImpl("net461", "angular"); => SpaTemplateImpl("net461", "angular");
[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)]
public void AngularTemplate_NoHttps_Works_NetFramework()
=> SpaTemplateImpl("net461", "angular", true);
[Fact] [Fact]
public void AngularTemplate_Works_NetCore() public void AngularTemplate_Works_NetCore()
=> SpaTemplateImpl(null, "angular"); => SpaTemplateImpl(null, "angular");

View File

@ -19,9 +19,9 @@ namespace Templates.Test.SpaTemplateTest
// Rather than using [Theory] to pass each of the different values for 'template', // Rather than using [Theory] to pass each of the different values for 'template',
// it's important to distribute the SPA template tests over different test classes // it's important to distribute the SPA template tests over different test classes
// so they can be run in parallel. Xunit doesn't parallelize within a test class. // so they can be run in parallel. Xunit doesn't parallelize within a test class.
protected void SpaTemplateImpl(string targetFrameworkOverride, string template) protected void SpaTemplateImpl(string targetFrameworkOverride, string template, bool noHttps = false)
{ {
RunDotNetNew(template, targetFrameworkOverride); RunDotNetNew(template, targetFrameworkOverride, noHttps: noHttps);
// For some SPA templates, the NPM root directory is './ClientApp'. In other // For some SPA templates, the NPM root directory is './ClientApp'. In other
// templates it's at the project root. Strictly speaking we shouldn't have // templates it's at the project root. Strictly speaking we shouldn't have