From 6827bb74436760aa3bb20934a1a1da4933062acb Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Tue, 12 Feb 2019 06:08:11 -0800 Subject: [PATCH] [Templating] Razor class library for components (#7461) * [Components] Razor class library for components * Updates the Razor Class Library to be a portable components library by default. * Adds an option to support the old RCL that includes support for Views and pages. * Usage: * `dotnet new razorclasslib` produces the same traditional Razor Class Library. * `dotnet new razorclasslib -s false` produces a Razor Class Library without views and pages support. --- .../Microsoft.DotNet.Web.ProjectTemplates.csproj | 1 + .../RazorClassLibrary-CSharp.csproj.in | 9 +++++++-- .../.template.config/dotnetcli.host.json | 4 ++++ .../.template.config/template.json | 16 ++++++++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj b/src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj index 44fba9a0dc..91586b5531 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj +++ b/src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj @@ -25,6 +25,7 @@ + diff --git a/src/ProjectTemplates/Web.ProjectTemplates/RazorClassLibrary-CSharp.csproj.in b/src/ProjectTemplates/Web.ProjectTemplates/RazorClassLibrary-CSharp.csproj.in index c7a7314001..79270c3102 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/RazorClassLibrary-CSharp.csproj.in +++ b/src/ProjectTemplates/Web.ProjectTemplates/RazorClassLibrary-CSharp.csproj.in @@ -1,12 +1,17 @@ - netcoreapp3.0 + netcoreapp3.0 + netstandard2.0 Company.RazorClassLibrary1 - + + + + + diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorClassLibrary-CSharp/.template.config/dotnetcli.host.json b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorClassLibrary-CSharp/.template.config/dotnetcli.host.json index 709f1b9629..c658c087dd 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorClassLibrary-CSharp/.template.config/dotnetcli.host.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorClassLibrary-CSharp/.template.config/dotnetcli.host.json @@ -8,6 +8,10 @@ "skipRestore": { "longName": "no-restore", "shortName": "" + }, + "SupportPagesAndViews": { + "longName": "support-pages-and-views", + "shortName": "s" } } } diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorClassLibrary-CSharp/.template.config/template.json b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorClassLibrary-CSharp/.template.config/template.json index 47000e198f..405e29cca7 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/RazorClassLibrary-CSharp/.template.config/template.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/RazorClassLibrary-CSharp/.template.config/template.json @@ -20,6 +20,16 @@ }, "sourceName": "Company.RazorClassLibrary1", "preferNameDirectory": true, + "sources": [ + { + "modifiers": [{ + "condition": "(!SupportPagesAndViews)", + "exclude": [ + "Areas/**" + ] + }] + } + ], "symbols": { "Framework": { "type": "parameter", @@ -42,6 +52,12 @@ "datatype": "bool", "description": "If specified, skips the automatic restore of the project on create.", "defaultValue": "false" + }, + "SupportPagesAndViews": { + "type": "parameter", + "datatype": "bool", + "defaultValue": "true", + "description": "Whether to support adding traditional Razor pages and Views in addition to components to this library." } }, "primaryOutputs": [