dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.

Home Page:https://asp.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

TanayParikh opened this issue · comments

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.

Originally posted by @phenning in #42215 (comment)

@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?):

"id": "openInEditor",
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")",
"description": "Opens Areas/MyFeature/Pages/Page1.cshtml in the editor",
"manualInstructions": [],
"actionId": "84C0DA21-51C8-4541-9940-6CA19AF04EE6",
"args": {
"files": "1"
},
"continueOnError": true

@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?):

"id": "openInEditor",
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")",
"description": "Opens Areas/MyFeature/Pages/Page1.cshtml in the editor",
"manualInstructions": [],
"actionId": "84C0DA21-51C8-4541-9940-6CA19AF04EE6",
"args": {
"files": "1"
},
"continueOnError": true

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.

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

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.

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