dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.5k stars 10.04k forks source link

Add Blazor templates for ASP.NET Core 2.1 #16282

Closed danroth27 closed 5 years ago

danroth27 commented 6 years ago

Looks like there is quite a bit of drop off in the number of people that successfully create a Blazor template after getting the VSIX. One hypothesis is that they can't find the templates. Currently the Blazor templates only show up if you select .NET Core and ASP.NET Core 2.0 in the "New ASP.NET Core Web Application" dialog. It would help if the Blazor templates showed up when the .NET Framework is selected and for ASP.NET Core 2.1.

redowl3 commented 6 years ago

I would guess it's more to do with whether Blazor moves from experimental to supported. If MSFT would hurry up and confirm it's going ahead you would get more usage.

danroth27 commented 6 years ago

Add additional framework option for 2.0, and the associated conditions to pull in the right package versions in your csproj.

For full framework, the template needs to:

  1. Define TargetFrameworkOverride: https://github.com/dotnet/templating/blob/d18c42fe62ca500bfd1afbaa7a6382180dff52ef/template_feed/Microsoft.DotNet.Common.ProjectTemplates.1.x/content/ClassLibrary-CSharp/.template.config/template.json#L33
  2. Hide it from the CLI: https://github.com/dotnet/templating/blob/d18c42fe62ca500bfd1afbaa7a6382180dff52ef/template_feed/Microsoft.DotNet.Common.ProjectTemplates.1.x/content/ClassLibrary-CSharp/.template.config/dotnetcli.host.json#L4
  3. Support it in the template content: https://github.com/dotnet/templating/blob/d18c42fe62ca500bfd1afbaa7a6382180dff52ef/template_feed/Microsoft.DotNet.Common.ProjectTemplates.1.x/content/ClassLibrary-CSharp/Company.ClassLibrary1.csproj#L4-L5.
chrissainty commented 6 years ago

@danroth27 I'm happy to have a go at this one. Is it just a case of updating the various json files in the .template.config folders for each of the two templates and the .csproj files?

danroth27 commented 6 years ago

We think so, but we'll have to test to make sure. Feel free to have a go at it!

chrissainty commented 6 years ago

I'm about there with the changes. I've just got one question. In the BlazorHosted.CSharp.Server.csproj file the project is targeting netstandard2.0 and not netcoreapp2.0 is there a specific reason for this?

danroth27 commented 6 years ago

@chrissainty The server project is an ASP.NET Core project that runs on .NET Core, so it targets netcoreapp2.0. The client project is a Blazor app, which currently should target netstandard2.0.

chrissainty commented 6 years ago

@danroth27 Apologies my copy of that file was targeting netstandard2.0 not netcoreapp2.0 hence the question. Not sure how that happened, I'll get it updated.

danroth27 commented 6 years ago

@SteveSandersonMS I think this one is done, correct?