Skip to content

Fix Blazor Identity output path for renamed project folders - #3803

Merged
danroth27 merged 1 commit into
mainfrom
danroth27/fix-blazor-identity-output-path
Aug 19, 2026
Merged

danroth27 merged 1 commit into
mainfrom
danroth27/fix-blazor-identity-output-path

Conversation

@danroth27

@danroth27 danroth27 commented Aug 18, 2026 •

Copy link
Copy Markdown
Member

Fixes #3716.

Blazor Identity generated component paths through namespace-to-path conversion, which assumes the project directory name matches the project file name. The separately copied PasskeySubmit.razor.js already used an explicit Components/Account/Shared path, causing the script and its Razor component to be split when a project was copied or renamed.

Centralize the Blazor Identity component root in BlazorIdentityHelper.GetIdentityComponentsPath and use it for both generated Identity files and the passkey JavaScript. The shared StringUtil.ToPath contract and other scaffolders remain unchanged.

The existing Blazor Identity integration fixture now deliberately uses a directory name that differs from TestProject.csproj, so its existing file-placement and post-scaffolding build assertions cover the regression across target frameworks. The .NET 10 and .NET 11 tests also verify that PasskeySubmit.razor.js is emitted in the same Components/Account/Shared directory as its Razor component.

Validation:

  • dotnet-scaffold net10.0 build: passed with 0 warnings and 0 errors
  • Blazor Identity helper and builder-extension tests: passed
  • .NET 10 Blazor Identity renamed-directory integration test: passed
  • Full BlazorWebAppMovies end-to-end workflow from BlazorWebAppMoviesAuthorization: 40 Razor components generated under Components/Account, passkey component and script colocated, no extra project-name folder, post-scaffold build succeeded, / and /Account/Login returned HTTP 200, and the fingerprinted passkey module returned HTTP 200 in Development

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adjusts Blazor Identity scaffolding path construction so generated file output paths are resolved relative to the project directory (instead of always inserting a project-name folder derived from the project file name), addressing the extra nested folder problem when the project’s directory name differs from the project name.

Changes:

  • Updates StringUtil.ToPath to stop unconditionally adding the project root namespace as a directory segment, and to strip the root namespace from the target namespace when building relative paths.
  • Adds a regression test covering the “project directory differs from project file name” scenario for Blazor Identity template output paths.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
test/dotnet-scaffolding/dotnet-scaffold.Tests/AspNet/Helpers/BlazorIdentityHelperTests.cs Adds a regression test ensuring generated Identity component output paths are rooted at the actual project directory.
src/dotnet-scaffolding/Microsoft.DotNet.Scaffolding.Internal/StringUtil.cs Changes namespace-to-path conversion to avoid introducing an extra project-name directory segment.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@danroth27

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@danroth27
danroth27 requested a review from haileymck August 18, 2026 04:52
haileymck
haileymck previously approved these changes Aug 18, 2026
Resolve generated Identity files relative to the actual project directory so copied or renamed project folders do not receive an extra project-name directory. Keep the passkey JavaScript colocated with its Razor component and cover the renamed-directory scenario in integration tests.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 82b2a814-e47f-4714-9181-58f8a090bc5e
@danroth27
danroth27 force-pushed the danroth27/fix-blazor-identity-output-path branch from 87ab78e to fad21c8 Compare August 18, 2026 18:52
@danroth27
danroth27 enabled auto-merge (squash) August 18, 2026 18:54
@guardrex

guardrex commented Aug 18, 2026 •

Copy link
Copy Markdown

Thanks for this! 🎉 Could either of you let me know when ... or approximately when ... these updates will reach the public package? When they become available, I can resolve the updates for the last authz node article overhaul.

@haileymck

Copy link
Copy Markdown
Member

@guardrex It will hit the public preview in a few weeks and then the public stable towards mid September! Thanks for your patience

@danroth27
danroth27 merged commit fa1e634 into main Aug 19, 2026
16 checks passed
@danroth27
danroth27 deleted the danroth27/fix-blazor-identity-output-path branch August 19, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blazor Identity scaffolds Identity into the wrong folder when a db context already exists

4 participants