-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Fix. Creating a Blazor project with a space in its name breaks the styling #62675
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
Fix. Creating a Blazor project with a space in its name breaks the styling #62675
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures that Blazor projects with spaces in their names generate valid style bundle filenames by replacing spaces with underscores and updating the App.razor stylesheet reference accordingly.
- Added a new
StyleBundleName
regex generator in the template configuration to sanitize project names. - Updated the App.razor component to reference the dynamically generated bundle name.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/.template.config/template.json | Introduced StyleBundleName symbol with regex replacement steps. |
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/App.razor | Switched stylesheet link to use StyleBundleName.styles.css . |
@@ -10,7 +10,7 @@ | |||
<link rel="stylesheet" href="@Assets["lib/bootstrap/dist/css/bootstrap.min.css"]" /> | |||
##endif*@ | |||
<link rel="stylesheet" href="@Assets["app.css"]" /> | |||
<link rel="stylesheet" href="@Assets["BlazorWebCSharp.1.styles.css"]" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know what this .1
is for? (Just surprised to see it there)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, I think I found the commit in the history that made this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My theory is that this is a default name and it is through the whole template project, which will be then replaced with the user's chosen name, because folders are name like that and they get replaced with the RootName.
Fix. Creating a Blazor project with a space in its name breaks the styling
Description
StyleBundleName
generator to thesrc/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/.template.config/template.json
file. This generator uses a regex-based transformation to replace spaces in the project name with underscores for it to be aligned with the sanitized assembly name.src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/App.razor
file to use the dynamically generatedStyleBundleName
for the stylesheet reference, replacing the previously incorrectly bound value.Fixes #52196