Repository navigation
Fix Blazor Identity output path for renamed project folders - #3803
Conversation
There was a problem hiding this comment.
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.ToPathto 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.
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
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
87ab78e to
fad21c8
Compare
|
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. |
|
@guardrex It will hit the public preview in a few weeks and then the public stable towards mid September! Thanks for your patience |
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.jsalready used an explicitComponents/Account/Sharedpath, 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.GetIdentityComponentsPathand use it for both generated Identity files and the passkey JavaScript. The sharedStringUtil.ToPathcontract 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 thatPasskeySubmit.razor.jsis emitted in the sameComponents/Account/Shareddirectory as its Razor component.Validation:
dotnet-scaffoldnet10.0 build: passed with 0 warnings and 0 errorsBlazorWebAppMoviesend-to-end workflow fromBlazorWebAppMoviesAuthorization: 40 Razor components generated underComponents/Account, passkey component and script colocated, no extra project-name folder, post-scaffold build succeeded,/and/Account/Loginreturned HTTP 200, and the fingerprinted passkey module returned HTTP 200 in Development