Skip to content

Use SDK Asset Groups for Assets.Internal and Identity UI#66412

Merged
javiercn merged 9 commits into
mainfrom
javiercn/asset-groups-integration
Jun 1, 2026
Merged

Use SDK Asset Groups for Assets.Internal and Identity UI#66412
javiercn merged 9 commits into
mainfrom
javiercn/asset-groups-integration

Conversation

@javiercn

Copy link
Copy Markdown
Member

Replace custom build/props/targets packaging with SDK StaticWebAssetGroupDefinition and StaticWebAssetGroup items (dotnet/sdk#53187).

Assets.Internal changes:

  • Switch to Microsoft.NET.Sdk.Razor SDK
  • Add StaticWebAssetFrameworkPattern=**/*.js for framework asset marking
  • Use Content items with Link/ContentRoot metadata instead of custom _BlazorJSFile
  • Add StaticWebAssets.Groups.targets for consumer-side conditional inclusion
  • Remove BlazorWebAssemblyJSPath (no longer needed with framework assets)
  • Delete old build/, buildMultiTargeting/, buildTransitive/ directories

Identity UI changes:

  • Replace custom GetIdentityUIAssets target with StaticWebAssetGroupDefinition for Bootstrap V4/V5 variants
  • Add StaticWebAssets.Groups.targets for consumer-side group selection
  • Delete old build/, buildMultiTargeting/, buildTransitive/ directories

Consumer migration:

  • Components/Directory.Build.props: ProjectReference with PrivateAssets=All
    • Groups.targets import (replaces workaround properties)
  • Components/Directory.Build.targets: Remove BlazorWebAssemblyJSPath override
  • Identity samples/testassets: Import Groups.targets, remove old targets

Copilot AI review requested due to automatic review settings April 21, 2026 21:03
@javiercn javiercn requested a review from a team as a code owner April 21, 2026 21:03
@github-actions github-actions Bot added the area-identity Includes: Identity and providers label Apr 21, 2026
@javiercn javiercn force-pushed the javiercn/asset-groups-integration branch from 1e93176 to 688db7f Compare April 21, 2026 21:07

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 migrates internal static web asset packaging for Microsoft.AspNetCore.App.Internal.Assets and Microsoft.AspNetCore.Identity.UI from custom build/props/targets to the .NET SDK’s StaticWebAssetGroupDefinition / StaticWebAssetGroup mechanism, and updates repo consumers (Components + Identity samples/testassets) to select asset groups via new StaticWebAssets.Groups.targets convention files.

Changes:

  • Switch asset delivery to SDK asset groups (Assets.Internal “BlazorFramework” group; Identity UI “BootstrapVersion” V4/V5 groups) and remove the legacy build/, buildMultiTargeting/, and buildTransitive/ packaging artifacts.
  • Update repo consumers to import the new StaticWebAssets.Groups.targets files and remove the previous workaround targets/properties.
  • Simplify Components build settings by removing the BlazorWebAssemblyJSPath override.

Reviewed changes

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

Show a summary per file
File Description
src/Identity/testassets/Identity.DefaultUI.WebSite/Identity.DefaultUI.WebSite.csproj Switches to IdentityUIFrameworkVersion and imports Identity UI group-selection targets; removes legacy MSBuild wiring.
src/Identity/samples/IdentitySample.PasskeyUI/IdentitySample.PasskeyUI.csproj Replaces the old Blazor framework assets workaround with an Assets.Internal reference + group-selection import.
src/Identity/samples/IdentitySample.DefaultUI/IdentitySample.DefaultUI.csproj Imports Identity UI group-selection targets and removes legacy MSBuild wiring.
src/Identity/UI/src/buildTransitive/Microsoft.AspNetCore.Identity.UI.targets Removes legacy transitive targets shim.
src/Identity/UI/src/buildMultiTargeting/Microsoft.AspNetCore.Identity.UI.targets Removes legacy multitargeting targets shim.
src/Identity/UI/src/build/Microsoft.AspNetCore.StaticWebAssets.targets Removes legacy conditional Bootstrap V4/V5 static web asset imports.
src/Identity/UI/src/build/Microsoft.AspNetCore.Identity.UI.targets Removes legacy targets import.
src/Identity/UI/src/build/Microsoft.AspNetCore.Identity.UI.props Removes legacy props that set default UI framework + assembly attribute.
src/Identity/UI/src/StaticWebAssets.Groups.targets Adds consumer-side group selection (BootstrapVersion) + assembly attribute injection.
src/Identity/UI/src/Microsoft.AspNetCore.Identity.UI.csproj Defines BootstrapVersion asset groups via SDK items; packs assets via Content discovery.
src/Components/Directory.Build.targets Removes BlazorWebAssemblyJSPath override and replaces with explanatory comment.
src/Components/Directory.Build.props Adds Assets.Internal reference + imports Assets group-selection targets in Components area.
src/Assets/buildTransitive/Microsoft.AspNetCore.App.Internal.Assets.targets Removes legacy transitive targets shim.
src/Assets/buildMultiTargeting/Microsoft.AspNetCore.App.Internal.Assets.targets Removes legacy multitargeting targets shim.
src/Assets/build/Microsoft.AspNetCore.App.Internal.Assets.targets Removes legacy custom target that injected framework static web assets.
src/Assets/build/Microsoft.AspNetCore.App.Internal.Assets.props Removes legacy (empty) props.
src/Assets/StaticWebAssets.Groups.targets Adds consumer-side deferred group selection for the “BlazorFramework” asset group.
src/Assets/Microsoft.AspNetCore.App.Internal.Assets.csproj Switches to Razor SDK; packs framework JS as static web assets and defines the “BlazorFramework” asset group.
Directory.Build.targets Updates repo-level comment to reflect new consumption pattern (ProjectReference + Groups targets convention).

Comment thread src/Identity/samples/IdentitySample.PasskeyUI/IdentitySample.PasskeyUI.csproj Outdated
Comment thread src/Components/Directory.Build.props Outdated
Comment thread src/Components/Directory.Build.targets Outdated
Comment thread src/Identity/UI/src/StaticWebAssets.Groups.targets
@javiercn javiercn force-pushed the javiercn/asset-groups-integration branch 3 times, most recently from 4941a2d to 974ddd8 Compare April 21, 2026 22:27
@javiercn

Copy link
Copy Markdown
Member Author

@copilot

Check failure on line 0 in src/Components/Testing/tasks/Microsoft.AspNetCore.Components.Testing.Tasks.csproj

@azure-pipelines
azure-pipelines
/ aspnetcore-ci
src/Components/Testing/tasks/Microsoft.AspNetCore.Components.Testing.Tasks.csproj#L0

src/Components/Testing/tasks/Microsoft.AspNetCore.Components.Testing.Tasks.csproj(0,0): error NU1201: (NETCORE_ENGINEERING_TELEMETRY=Restore) Project Microsoft.AspNetCore.App.Internal.Assets is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Project Microsoft.AspNetCore.App.Internal.Assets supports: net11.0 (.NETCoreApp,Version=v11.0)
Check failure on line 0 in src/Components/Testing/gen/Microsoft.AspNetCore.Components.Testing.Generators.csproj

@azure-pipelines
azure-pipelines
/ aspnetcore-ci
src/Components/Testing/gen/Microsoft.AspNetCore.Components.Testing.Generators.csproj#L0

src/Components/Testing/gen/Microsoft.AspNetCore.Components.Testing.Generators.csproj(0,0): error NU1201: (NETCORE_ENGINEERING_TELEMETRY=Restore) Project Microsoft.AspNetCore.App.Internal.Assets is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Project Microsoft.AspNetCore.App.Internal.Assets supports: net11.0 (.NETCoreApp,Version=v11.0)
Check failure on line 0 in src/Components/Analyzers/src/Microsoft.AspNetCore.Components.Analyzers.csproj

@azure-pipelines
azure-pipelines
/ aspnetcore-ci
src/Components/Analyzers/src/Microsoft.AspNetCore.Components.Analyzers.csproj#L0

src/Components/Analyzers/src/Microsoft.AspNetCore.Components.Analyzers.csproj(0,0): error NU1201: (NETCORE_ENGINEERING_TELEMETRY=Restore) Project Microsoft.AspNetCore.App.Internal.Assets is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Project Microsoft.AspNetCore.App.Internal.Assets supports: net11.0 (.NETCoreApp,Version=v11.0)
Check failure on line 0 in src/Components/Testing/tasks/Microsoft.AspNetCore.Components.Testing.Tasks.csproj

@azure-pipelines
azure-pipelines
/ aspnetcore-ci
src/Components/Testing/tasks/Microsoft.AspNetCore.Components.Testing.Tasks.csproj#L0

src/Components/Testing/tasks/Microsoft.AspNetCore.Components.Testing.Tasks.csproj(0,0): error NU1201: (NETCORE_ENGINEERING_TELEMETRY=Restore) Project Microsoft.AspNetCore.App.Internal.Assets is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Project Microsoft.AspNetCore.App.Internal.Assets supports: net11.0 (.NETCoreApp,Version=v11.0)

fix them.

Copilot AI commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

@copilot

Check failure on line 0 in src/Components/Testing/tasks/Microsoft.AspNetCore.Components.Testing.Tasks.csproj...

Fixed in bd2fbfc. The Directory.Build.props condition now excludes projects targeting netstandard* from the Microsoft.AspNetCore.App.Internal.Assets reference, since that package only supports net11.0 and build tools/analyzers (Testing Tasks, Testing Generators, Analyzers) target netstandard2.0.

@javiercn

Copy link
Copy Markdown
Member Author

@copilot
Check failure on line 0 in src/Components/Testing/tasks/Microsoft.AspNetCore.Components.Testing.Tasks.csproj...

Fixed in bd2fbfc. The Directory.Build.props condition now excludes projects targeting netstandard* from the Microsoft.AspNetCore.App.Internal.Assets reference, since that package only supports net11.0 and build tools/analyzers (Testing Tasks, Testing Generators, Analyzers) target netstandard2.0.

Hmm, note that Assets.Internal shouldn't generate any assembly or show as a dependency of any other library/package, make sure that's the case

Copilot AI commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

@copilot
[Check failure on line 0 in src/Components/Testing/tasks/Microsoft.AspNetCore.Components.Testing.Tasks.csproj](https://github.com/dotnet/aspnetcore/pull/66412/files#annotation_523891...

Addressed in 1beec52. The Internal.Assets project has IncludeBuildOutput=false so no assembly is included in the NuGet package. To ensure it also doesn't show as a dependency in consuming libraries/packages, I added a top-level ItemGroup in src/Components/Directory.Build.targets (after the parent import, so it runs after ResolveReferences.targets' Reference→ProjectReference conversion) that updates the ProjectReference with PrivateAssets=All and Private=false. The Reference→ProjectReference conversion drops all metadata, so this is where it needs to be applied.

@javiercn

Copy link
Copy Markdown
Member Author

azure-pipelines
/ aspnetcore-ci (Build Build: Windows x64/x86/arm64)

.dotnet\sdk\11.0.100-preview.4.26210.111\NuGet.Build.Tasks.Pack.targets#L222
.dotnet\sdk\11.0.100-preview.4.26210.111\NuGet.Build.Tasks.Pack.targets(222,5): error NU5118: (NETCORE_ENGINEERING_TELEMETRY=Build) Warning As Error: File 'D:\a_work\1\s\src\Identity\UI\src\assets\V5\css\site.css' is not added because the package already contains file 'staticwebassets\css\site.css'
Check failure on line 222 in .dotnet\sdk\11.0.100-preview.4.26210.111\NuGet.Build.Tasks.Pack.targets

@azure-pipelines
azure-pipelines
/ aspnetcore-ci (Build Build: Windows x64/x86/arm64)

.dotnet\sdk\11.0.100-preview.4.26210.111\NuGet.Build.Tasks.Pack.targets#L222
.dotnet\sdk\11.0.100-preview.4.26210.111\NuGet.Build.Tasks.Pack.targets(222,5): error NU5118: (NETCORE_ENGINEERING_TELEMETRY=Build) Warning As Error: File 'D:\a_work\1\s\src\Identity\UI\src\assets\V5\favicon.ico' is not added because the package already contains file 'staticwebassets\favicon.ico'
Check failure on line 222 in .dotnet\sdk\11.0.100-preview.4.26210.111\NuGet.Build.Tasks.Pack.targets

@azure-pipelines
azure-pipelines
/ aspnetcore-ci (Build Build: Windows x64/x86/arm64)

.dotnet\sdk\11.0.100-preview.4.26210.111\NuGet.Build.Tasks.Pack.targets#L222
.dotnet\sdk\11.0.100-preview.4.26210.111\NuGet.Build.Tasks.Pack.targets(222,5): error NU5118: (NETCORE_ENGINEERING_TELEMETRY=Build) Warning As Error: File 'D:\a_work\1\s\src\Identity\UI\src\assets\V5\js\site.js' is not added because the package already contains file 'staticwebassets\js\site.js'
Check failure on line 222 in .dotnet\sdk\11.0.100-preview.4.26210.111\NuGet.Build.Tasks.Pack.targets

@azure-pipelines
azure-pipelines
/ aspnetcore-ci (Build Build: Windows x64/x86/arm64)

.dotnet\sdk\11.0.100-preview.4.26210.111\NuGet.Build.Tasks.Pack.targets#L222
.dotnet\sdk\11.0.100-preview.4.26210.111\NuGet.Build.Tasks.Pack.targets(222,5): error NU5118: (NETCORE_ENGINEERING_TELEMETRY=Build) Warning As Error: File 'D:\a_work\1\s\src\Identity\UI\src\assets\V5\lib\bootstrap\LICENSE' is not added because the package already contains file 'staticwebassets\lib\bootstrap\LICENSE'
Check failure on line 222 in .dotnet\sdk\11.0.100-preview.4.26210.111\NuGet.Build.Tasks.Pack.targets

@azure-pipelines
azure-pipelines
/ aspnetcore-ci (Build Build: Windows x64/x86/arm64)

.dotnet\sdk\11.0.100-preview.4.26210.111\NuGet.Build.Tasks.Pack.targets#L222
.dotnet\sdk\11.0.100-preview.4.26210.111\NuGet.Build.Tasks.Pack.targets(222,5): error NU5118: (NETCORE_ENGINEERING_TELEMETRY=Build) Warning As Error: File 'D:\a_work\1\s\src\Identity\UI\src\assets\V5\lib\bootstrap\dist\css\bootstrap-grid.css' is not added because the package already contains file 'staticwebassets\lib\bootstrap\dist\css\bootstrap-grid.css'

@copilot we are missing the pack only pattern in the group definitions. Look inside the swa sdk in the local .net to find it, or search the dotnet/sdk repo for samples.

Copilot AI commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

azure-pipelines
/ aspnetcore-ci (Build Build: Windows x64/x86/arm64)

...

Fixed in b7b2ede. Added RelativePathPrefix="[{V4}/]~" and RelativePathPrefix="[{V5}/]~" to the respective StaticWebAssetGroupDefinition items in the Identity UI csproj. This causes each group variant to pack under a distinct path (staticwebassets/[{V4}/]~css/site.css vs staticwebassets/[{V5}/]~css/site.css), resolving the NU5118 duplicate-file conflict. Validated by packing a minimal reproducer and cracking open the nupkg — both variants land at separate paths with no errors, StaticWebAssets.Groups.targets is included in build/ and wired into the import chain.

@javiercn javiercn force-pushed the javiercn/asset-groups-integration branch 2 times, most recently from 97af508 to bada73f Compare April 23, 2026 08:53
@javiercn javiercn force-pushed the javiercn/asset-groups-integration branch from bada73f to 877e2f7 Compare May 18, 2026 10:37
@javiercn javiercn requested review from a team and wtgodbe as code owners May 18, 2026 10:37
Comment thread src/Components/Samples/BlazorUnitedApp/BlazorUnitedApp.csproj Outdated
Comment thread src/Components/test/testassets/Components.TestServer/Components.TestServer.csproj Outdated
@javiercn javiercn requested review from a team, BrennanConroy and halter73 as code owners May 28, 2026 11:34
javiercn and others added 9 commits May 28, 2026 13:38
….WebAssembly

Replace custom build/props/targets packaging with SDK StaticWebAssetGroupDefinition
and StaticWebAssetGroup items (dotnet/sdk#53187).

Assets.Internal changes:
- Switch to Microsoft.NET.Sdk.Razor SDK
- Add StaticWebAssetFrameworkPattern=**/*.js for framework asset marking
- Use Content items with Link/ContentRoot metadata instead of custom _BlazorJSFile
- Add StaticWebAssets.Groups.targets for consumer-side conditional inclusion
- Remove blazor.webassembly.js (now provided by Components.WebAssembly)
- Delete old build/, buildMultiTargeting/, buildTransitive/ directories

Components.WebAssembly changes:
- Switch to Microsoft.NET.Sdk.Razor SDK
- Add StaticWebAssetFrameworkPattern=**/*.js for framework asset marking
- Use Content items with Link/ContentRoot metadata for blazor.webassembly.js
- Add StaticWebAssetGroupDefinition + StaticWebAssets.Groups.targets
  (group keyed on UsingMicrosoftNETSdkBlazorWebAssembly)
- Remove BlazorWebAssemblyJSPath from package props (SWA pipeline handles it)

Identity UI changes:
- Replace custom GetIdentityUIAssets target with StaticWebAssetGroupDefinition
  for Bootstrap V4/V5 variants
- Add StaticWebAssets.Groups.targets for consumer-side group selection
- Delete old build/, buildMultiTargeting/, buildTransitive/ directories

Consumer migration:
- Components/Directory.Build.props: ProjectReference with PrivateAssets=All
  + Groups.targets imports (replaces workaround properties)
- Components/Directory.Build.targets: Remove BlazorWebAssemblyJSPath override
- Identity samples/testassets: Import Groups.targets, remove old targets
The _ConfigureAssetsInternalReference target set ReferenceOutputAssembly=false
during target execution (BeforeTargets=ResolveProjectReferences), but the E2E
test pipeline invokes Components.TestServer and Wasm.Prerendered.Server with
Targets='Build;Publish' and custom Properties, creating separate MSBuild project
instances where the target-based approach didn't reliably prevent the compiler
from trying to reference the non-existent Assets.Internal DLL.

By setting the metadata via ProjectReference Update at evaluation time (outside
any target), the metadata is always in effect regardless of which targets run or
how many times the project is built with different global properties.
…ojects

The BlazorWebAssembly group on blazor.webassembly.js should be cleared by
the SDK when the asset crosses project boundaries as a framework asset.
Until that SDK change is in place, declare the group in each hosting
server project so the asset passes filtering.

Simplify Assets.Internal groups to only declare BlazorFramework.
Restore WebAssembly groups to final form (BlazorWebAssembly SDK only).
The original _AddBlazorFrameworkStaticWebAssets target required both
OutputType == Exe/WinExe AND UsingMicrosoftNETSdkWeb. The group
condition must match: only executable web apps should opt into the
BlazorFramework group for blazor.web.js and blazor.server.js.
Change JS build output to include _framework/ in the directory structure
so that it becomes part of RelativePath rather than BasePath. This ensures
the _framework prefix survives framework asset materialization regardless
of the consumer's BasePath.

Changes:
- Rollup config outputs to dist/Debug/_framework/blazor.*.js
- Assets.Internal and WebAssembly csprojs: BasePath=/ with _framework in paths
- Remove StaticWebAssetGroup workarounds from test/sample projects (no longer
  needed since the SDK properly filters by group before materialization)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Javier Calvarro Nelson <jacalvar@microsoft.com>
The StaticWebAssets.Groups.targets now falls back to the existing
IdentityDefaultUIFramework property if IdentityUIFrameworkVersion is
not explicitly set, so consuming projects don't need to rename their
property.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Update global.json to 11.0.100-preview.6.26277.116
- Remove redundant Microsoft.Extensions.Options reference in Validation
  Localization tests (NU1510 warns-as-error with new SDK pruning)
- Fix stale comment in Components Directory.Build.targets about which
  package provides blazor.webassembly.js

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@javiercn javiercn force-pushed the javiercn/asset-groups-integration branch from 4e7b826 to 6bc8197 Compare May 28, 2026 11:39
@javiercn javiercn enabled auto-merge (squash) June 1, 2026 10:49
@javiercn

javiercn commented Jun 1, 2026

Copy link
Copy Markdown
Member Author

/ba-g
image

Test are passed, but the reporting failed

@javiercn javiercn merged commit bc4e954 into main Jun 1, 2026
25 checks passed
@javiercn javiercn deleted the javiercn/asset-groups-integration branch June 1, 2026 10:51
@dotnet-policy-service dotnet-policy-service Bot added this to the 11.0-preview6 milestone Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-identity Includes: Identity and providers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants