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.38k stars 10k forks source link

Open `Index.razor` by default in `blazorserver`, `blazorwasm` templates #42330

Closed TanayParikh closed 2 years ago

TanayParikh commented 2 years ago

Razor class library does this.

Basically you want to have the file you want to open as a conditional secondary primaryOutput for non-CLI hosts, then add a post action.

https://github.com/dotnet/aspnetcore/blob/5026aefddd69322da633d4b29a3d24c4df0b51b9/src/ProjectTemplates/Web.ProjectTemplates/content/RazorClassLibrary-CSharp/.template.config/template.json#L99

_Originally posted by @phenning in https://github.com/dotnet/aspnetcore/pull/42215#discussion_r903146520_

TanayParikh commented 2 years ago

@phenning I'm not seeing where the file path is actually specified (I'm assuming the description isn't parsed for the path, is it?):

https://github.com/dotnet/aspnetcore/blob/5026aefddd69322da633d4b29a3d24c4df0b51b9/src/ProjectTemplates/Web.ProjectTemplates/content/RazorClassLibrary-CSharp/.template.config/template.json#L99-L107

phenning commented 2 years ago

@phenning I'm not seeing where the file path is actually specified (I'm assuming the description isn't parsed for the path, is it?):

https://github.com/dotnet/aspnetcore/blob/5026aefddd69322da633d4b29a3d24c4df0b51b9/src/ProjectTemplates/Web.ProjectTemplates/content/RazorClassLibrary-CSharp/.template.config/template.json#L99-L107

args.files is the zero based index into the primaryOutputs object array

"files": "1" or "files": "1;2" if you wanted to open multiple files.

https://github.com/dotnet/aspnetcore/blob/5026aefddd69322da633d4b29a3d24c4df0b51b9/src/ProjectTemplates/Web.ProjectTemplates/content/RazorClassLibrary-CSharp/.template.config/template.json#L81

javiercn commented 2 years ago

Is Index.razor what we want to open vs other things like Program.cs? Could we open both?

TanayParikh commented 2 years ago

Is Index.razor what we want to open vs other things like Program.cs? Could we open both?

Index.razor was just the first one to come to mind. Yeah we can definitely do program as well.

phenning commented 2 years ago

Now that I looked at the other web templates, I noticed none of the others are opening any files. Maybe we should do the same here. I just asked the question in case the team wanted to consider for this template. We might want to err on the side of consistency though