From 895e1c69e07f460c83b3b098466a81c7902df129 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Wed, 20 Feb 2019 13:16:05 +0000 Subject: [PATCH] Components/Blazor template updates (#7709) * In Blazor hosted template, only UseBlazorDebugging in development environment. Fixes #7275 * Enable HTTPS in the Razor Components template. Fixes #6928 * Reduce Razor Components template to one project. Fixes #6883 * Minor phrasing tweak * In Razor Components template, change .cshtml to .razor, except _ViewImports.cshtml * Put back LangVersion * Update RazorComponentsTemplateTest --- .../BlazorHosted-CSharp.Server/Startup.cs | 2 +- ...crosoft.DotNet.Web.ProjectTemplates.csproj | 3 +- .../RazorComponentsWeb-CSharp.App.csproj.in | 14 ----- ...in => RazorComponentsWeb-CSharp.csproj.in} | 8 ++- .../.template.config/template.json | 30 ++--------- .../App.cshtml => Components/App.razor} | 0 .../Pages/Counter.razor} | 2 +- .../Pages/FetchData.razor} | 6 +-- .../Pages/Index.razor} | 0 .../Pages/_ViewImports.cshtml | 0 .../Shared/MainLayout.razor} | 0 .../Shared/NavMenu.razor} | 2 +- .../Components/Startup.cs | 12 +++++ .../_ViewImports.cshtml | 3 +- .../Program.cs | 2 +- .../Properties/launchSettings.json | 35 ++++++++++++ .../RazorComponentsWeb-CSharp.App/Startup.cs | 20 ------- .../RazorComponentsWeb-CSharp.sln | 50 ------------------ .../Services/WeatherForecast.cs | 2 +- .../Services/WeatherForecastService.cs | 2 +- .../Startup.cs | 21 ++++++-- .../appsettings.Development.json | 0 .../appsettings.json | 0 .../wwwroot/css/bootstrap/bootstrap.min.css | 0 .../css/bootstrap/bootstrap.min.css.map | 0 .../wwwroot/css/open-iconic/FONT-LICENSE | 0 .../wwwroot/css/open-iconic/ICON-LICENSE | 0 .../wwwroot/css/open-iconic/README.md | 0 .../font/css/open-iconic-bootstrap.min.css | 0 .../open-iconic/font/fonts/open-iconic.eot | Bin .../open-iconic/font/fonts/open-iconic.otf | Bin .../open-iconic/font/fonts/open-iconic.svg | 0 .../open-iconic/font/fonts/open-iconic.ttf | Bin .../open-iconic/font/fonts/open-iconic.woff | Bin .../wwwroot/css/site.css | 0 .../wwwroot/index.html | 0 .../test/RazorComponentsTemplateTest.cs | 5 -- 37 files changed, 84 insertions(+), 135 deletions(-) delete mode 100644 src/ProjectTemplates/Web.ProjectTemplates/RazorComponentsWeb-CSharp.App.csproj.in rename src/ProjectTemplates/Web.ProjectTemplates/{RazorComponentsWeb-CSharp.Server.csproj.in => RazorComponentsWeb-CSharp.csproj.in} (70%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.App/App.cshtml => Components/App.razor} (100%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.App/Pages/Counter.cshtml => Components/Pages/Counter.razor} (92%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.App/Pages/FetchData.cshtml => Components/Pages/FetchData.razor} (87%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.App/Pages/Index.cshtml => Components/Pages/Index.razor} (100%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.App => Components}/Pages/_ViewImports.cshtml (100%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.App/Shared/MainLayout.cshtml => Components/Shared/MainLayout.razor} (100%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.App/Shared/NavMenu.cshtml => Components/Shared/NavMenu.razor} (95%) create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/Components/Startup.cs rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.App => Components}/_ViewImports.cshtml (64%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.Server => }/Program.cs (94%) create mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/Properties/launchSettings.json delete mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.App/Startup.cs delete mode 100644 src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.sln rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.App => }/Services/WeatherForecast.cs (83%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.App => }/Services/WeatherForecastService.cs (93%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.Server => }/Startup.cs (60%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.Server => }/appsettings.Development.json (100%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.Server => }/appsettings.json (100%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.Server => }/wwwroot/css/bootstrap/bootstrap.min.css (100%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.Server => }/wwwroot/css/bootstrap/bootstrap.min.css.map (100%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.Server => }/wwwroot/css/open-iconic/FONT-LICENSE (100%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.Server => }/wwwroot/css/open-iconic/ICON-LICENSE (100%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.Server => }/wwwroot/css/open-iconic/README.md (100%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.Server => }/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css (100%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.Server => }/wwwroot/css/open-iconic/font/fonts/open-iconic.eot (100%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.Server => }/wwwroot/css/open-iconic/font/fonts/open-iconic.otf (100%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.Server => }/wwwroot/css/open-iconic/font/fonts/open-iconic.svg (100%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.Server => }/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf (100%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.Server => }/wwwroot/css/open-iconic/font/fonts/open-iconic.woff (100%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.Server => }/wwwroot/css/site.css (100%) rename src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/{RazorComponentsWeb-CSharp.Server => }/wwwroot/index.html (100%) diff --git a/src/Components/Blazor/Templates/src/content/BlazorHosted-CSharp/BlazorHosted-CSharp.Server/Startup.cs b/src/Components/Blazor/Templates/src/content/BlazorHosted-CSharp/BlazorHosted-CSharp.Server/Startup.cs index 1d8c336ea6..e83a257039 100644 --- a/src/Components/Blazor/Templates/src/content/BlazorHosted-CSharp/BlazorHosted-CSharp.Server/Startup.cs +++ b/src/Components/Blazor/Templates/src/content/BlazorHosted-CSharp/BlazorHosted-CSharp.Server/Startup.cs @@ -25,6 +25,7 @@ namespace BlazorHosted_CSharp.Server if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); + app.UseBlazorDebugging(); } app.UseMvc(routes => @@ -33,7 +34,6 @@ namespace BlazorHosted_CSharp.Server }); app.UseBlazor(); - app.UseBlazorDebugging(); } } } diff --git a/src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj b/src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj index b210535d72..4f1917eb70 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj +++ b/src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj @@ -39,8 +39,7 @@ - - + diff --git a/src/ProjectTemplates/Web.ProjectTemplates/RazorComponentsWeb-CSharp.App.csproj.in b/src/ProjectTemplates/Web.ProjectTemplates/RazorComponentsWeb-CSharp.App.csproj.in deleted file mode 100644 index 6a4069f993..0000000000 --- a/src/ProjectTemplates/Web.ProjectTemplates/RazorComponentsWeb-CSharp.App.csproj.in +++ /dev/null @@ -1,14 +0,0 @@ - - - - netstandard2.0 - 7.3 - RazorComponentsWeb_CSharp.App - - - - - - - - diff --git a/src/ProjectTemplates/Web.ProjectTemplates/RazorComponentsWeb-CSharp.Server.csproj.in b/src/ProjectTemplates/Web.ProjectTemplates/RazorComponentsWeb-CSharp.csproj.in similarity index 70% rename from src/ProjectTemplates/Web.ProjectTemplates/RazorComponentsWeb-CSharp.Server.csproj.in rename to src/ProjectTemplates/Web.ProjectTemplates/RazorComponentsWeb-CSharp.csproj.in index 4f089b0076..a592f91495 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/RazorComponentsWeb-CSharp.Server.csproj.in +++ b/src/ProjectTemplates/Web.ProjectTemplates/RazorComponentsWeb-CSharp.csproj.in @@ -2,14 +2,12 @@ netcoreapp3.0 + 7.3 True - RazorComponentsWeb_CSharp.Server + RazorComponentsWeb_CSharp + <_RazorComponentInclude>Components\**\*.cshtml - - - - diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/.template.config/template.json b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/.template.config/template.json index fb5992cce0..8e67984aa2 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/.template.config/template.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/.template.config/template.json @@ -18,11 +18,6 @@ }, "sourceName": "RazorComponentsWeb-CSharp", "preferNameDirectory": true, - "guids": [ - "4C26868E-5E7C-458D-82E3-040509D0C71F", - "5990939C-7E7B-4CFA-86FF-44CA5756498A", - "650B3CE7-2E93-4CC4-9F46-466686815EAA" - ], "sources": [ { "modifiers": [ @@ -31,12 +26,6 @@ "exclude": [ "Properties/launchSettings.json" ] - }, - { - "condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")", - "exclude": [ - "*.sln" - ] } ] } @@ -48,10 +37,6 @@ "defaultValue": "false", "description": "Whether to exclude launchSettings.json from the generated template." }, - "HostIdentifier": { - "type": "bind", - "binding": "HostIdentifier" - }, "HttpPort": { "type": "parameter", "datatype": "integer", @@ -119,6 +104,10 @@ "description": "If specified, skips the automatic restore of the project on create.", "defaultValue": "false" }, + "RequiresHttps": { + "type": "computed", + "value": "(!NoHttps)" + }, "NoHttps": { "type": "parameter", "datatype": "bool", @@ -128,16 +117,7 @@ }, "primaryOutputs": [ { - "condition": "(HostIdentifier == \"dotnetcli\" || HostIdentifier == \"dotnetcli-preview\")", - "path": "RazorComponentsWeb-CSharp.sln" - }, - { - "condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")", - "path": "RazorComponentsWeb-CSharp.Server/RazorComponentsWeb-CSharp.Server.csproj" - }, - { - "condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")", - "path": "RazorComponentsWeb-CSharp.App/RazorComponentsWeb-CSharp.App.csproj" + "path": "RazorComponentsWeb-CSharp.csproj" } ], "defaultName": "WebApplication1", diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.App/App.cshtml b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/Components/App.razor similarity index 100% rename from src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.App/App.cshtml rename to src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/Components/App.razor diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.App/Pages/Counter.cshtml b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/Components/Pages/Counter.razor similarity index 92% rename from src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.App/Pages/Counter.cshtml rename to src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/Components/Pages/Counter.razor index 973af92354..e7244066a2 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.App/Pages/Counter.cshtml +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/Components/Pages/Counter.razor @@ -1,4 +1,4 @@ -@page "/counter" +@page "/counter"

Counter

diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.App/Pages/FetchData.cshtml b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/Components/Pages/FetchData.razor similarity index 87% rename from src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.App/Pages/FetchData.cshtml rename to src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/Components/Pages/FetchData.razor index 123e3a1e9a..6374201ea9 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.App/Pages/FetchData.cshtml +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/Components/Pages/FetchData.razor @@ -1,10 +1,10 @@ -@page "/fetchdata" -@using RazorComponentsWeb_CSharp.App.Services +@page "/fetchdata" +@using RazorComponentsWeb_CSharp.Services @inject WeatherForecastService ForecastService

Weather forecast

-

This component demonstrates fetching data from the server.

+

This component demonstrates fetching data from a service.

@if (forecasts == null) { diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.App/Pages/Index.cshtml b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/Components/Pages/Index.razor similarity index 100% rename from src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.App/Pages/Index.cshtml rename to src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/Components/Pages/Index.razor diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.App/Pages/_ViewImports.cshtml b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/Components/Pages/_ViewImports.cshtml similarity index 100% rename from src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.App/Pages/_ViewImports.cshtml rename to src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/Components/Pages/_ViewImports.cshtml diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.App/Shared/MainLayout.cshtml b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/Components/Shared/MainLayout.razor similarity index 100% rename from src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.App/Shared/MainLayout.cshtml rename to src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/Components/Shared/MainLayout.razor diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.App/Shared/NavMenu.cshtml b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/Components/Shared/NavMenu.razor similarity index 95% rename from src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.App/Shared/NavMenu.cshtml rename to src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/Components/Shared/NavMenu.razor index 4cb19c9ec1..34fc7d3f7c 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.App/Shared/NavMenu.cshtml +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorComponentsWeb-CSharp/Components/Shared/NavMenu.razor @@ -1,4 +1,4 @@ -