Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix MVC and Razor Pages scoped CSS styling for project names with spaces#62680

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Copilot wants to merge2 commits intomain
base:main
Choose a base branch
Loading
fromcopilot/fix-62679

Conversation

Copilot
Copy link
Contributor

@CopilotCopilotAI commentedJul 11, 2025
edited
Loading

This PR extends the fix from#62675 (Blazor scoped CSS space handling) to MVC and Razor Pages templates, ensuring that projects with spaces in their names have correctly functioning scoped CSS.

Problem

When creating MVC or Razor Pages projects with spaces in their names (e.g., "My Web App"), the scoped CSS bundle reference breaks because the hardcodedCompany.WebApplication1.styles.css reference doesn't match the actual generated bundle name, which sanitizes spaces to underscores.

Solution

Applied the sameStyleBundleName generator pattern used in the Blazor fix:

  1. Added StyleBundleName generator to both template.json files that uses regex to replace spaces with underscores:

    "StyleBundleName":{"type":"generated","generator":"regex","replaces":"StyleBundleName","parameters": {"source":"name","steps": [      {"regex":"","replacement":"_"      }]  }}
  2. Updated _Layout.cshtml files to use the dynamic StyleBundleName:

    <!-- Before --><linkrel="stylesheet"href="~/Company.WebApplication1.styles.css"asp-append-version="true"/><!-- After --><linkrel="stylesheet"href="~/StyleBundleName.styles.css"asp-append-version="true"/>

Testing

  • ✅ Template JSON validation passes
  • ✅ Integration tests verify correct CSS references for projects with spaces
  • ✅ Edge cases tested (multiple spaces, leading/trailing spaces, etc.)
  • ✅ Build system compiles templates successfully

Example

For a project named "My Web App":

  • Old: ReferencesCompany.WebApplication1.styles.css (broken)
  • New: ReferencesMy_Web_App.styles.css (works correctly)

This ensures that scoped CSS styling works consistently regardless of whether the project name contains spaces.

Fixes#62679.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Clickhere to start the survey.

@dotnet-policy-serviceDotnet Policy Service
Copy link
Contributor

Greetings human! You've submitted a PR that modifies code that is shared withhttps://github.com/dotnet/runtime . Please make sure you synchronize this code with the changes in that repo!

… space handlingCo-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
@CopilotCopilotAI changed the title[WIP] Creating an MVC/Razor pages project with a space in its name breaks the stylingFix MVC and Razor Pages scoped CSS styling for project names with spacesJul 11, 2025
@CopilotCopilotAI requested a review fromjaviercnJuly 11, 2025 15:09
Copilot finished work on behalf ofjaviercnJuly 11, 2025 15:09
@javiercn
Copy link
Member

@MackinnonBuck@joperezr in case you folks want to take this.@dariatiurina fixed it for Blazor.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@javiercnjaviercnAwaiting requested review from javiercn

@MackinnonBuckMackinnonBuckAwaiting requested review from MackinnonBuck

@joperezrjoperezrAwaiting requested review from joperezr

At least 1 approving review is required to merge this pull request.

Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Creating an MVC/Razor pages project with a space in its name breaks the styling
3 participants
@Copilot@javiercn@MackinnonBuck

[8]ページ先頭

©2009-2025 Movatter.jp