Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the Blazor Hybrid Solution template to work better with the dotnet cli or IDEs that rely on it. #25997

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jbw716
Copy link

@jbw716 jbw716 commented Nov 20, 2024

Description of Change

Updated the Blazor Hybrid Solution template to better support using the dotnet cli or IDEs that rely on it, like VSCode and Rider.

Issues Fixed

Excluding the .sln file doesn't make sense, since other IDEs can use the .sln file as well. If it's not needed, it can be deleted, much like other templates do. Not having it in the first place makes life significantly more difficult for users of this template on non Visual Studio environments.

Fixes #

Updated the template to remove the conditionals that exclude the .sln file for dotnetcli.

@jbw716 jbw716 requested a review from a team as a code owner November 20, 2024 19:31
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Nov 20, 2024
Copy link
Contributor

Hey there @jbw716! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@rmarinho
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@rmarinho rmarinho added area-blazor Blazor Hybrid / Desktop, BlazorWebView area-templates Project templates, Item Templates for Blazor and MAUI labels Nov 20, 2024
@rmarinho rmarinho requested a review from Eilon November 20, 2024 23:47
Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure that this is what you expect. The condition says to not create a sln in an IDE, because the IDE is already creating a sln - that is the only way for it to have multiple projects loaded at once.

Comment on lines 17 to 22
{
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")",
"path": "MauiApp.1.Shared/Pages/Home.razor"
},
{
"condition": "(HostIdentifier == \"dotnetcli\" || HostIdentifier == \"dotnetcli-preview\")",
"path": "MauiApp.1.sln"
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just telling VS that it should open these files. If you do this, the CLI will now have an error saying it can't open files.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally fair here. I am still relatively new to templates but trying to get this one to work for non-VS users.

Comment on lines 107 to 104
{
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")",
"exclude": [
"*.sln"
]
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to exclude the sln creation in VS because the IDE will have issues as it creates its own sln already.

Here is the ASP.NET templates doing just this: https://github.com/dotnet/aspnetcore/blob/main/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/.template.config/template.json#L116-L119

VSCode uses the CLI, so they will get the sln. Rider should be relying on the sln in the template because they will have their own as well. I would strongly suggest opening an issue on Rider's side if they are not creating a sln for a multi-project template.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not, then, check if VS and if so, exclude the sln? The template at the link you provided also does not provide a sln file, however, since it is only a single project template, it's not nearly as big of an issue.

Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please open an issue in the IDE that is not creating a sln as that is an IDE bug, not a behaviour that should be happening.

@jbw716
Copy link
Author

jbw716 commented Nov 21, 2024

I updated the PR with a new suggestion and better clarification around the issue.

@Eilon
Copy link
Member

Eilon commented Nov 22, 2024

Pinging @vijayrkn and @phenning to understand if this is logically the right change. @mattleibow is indeed correct with the intention of the logic: VS already creates SLNs automatically, so if we create one via the template then the world is less happy.

But then this same exact condition is copied in probably dozens of templates across multiple repos. I've never seen a check for vs before, so I want to make sure it's logically the right thing to do. (It seems logical, but I don't know the template infrastructure and behavior as well.)

Is there an example of a scenario that doesn't work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView area-templates Project templates, Item Templates for Blazor and MAUI community ✨ Community Contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants