Skip to content
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

Add package for consuming Blazor framework assets #58721

Merged
merged 22 commits into from
Nov 20, 2024

Conversation

MackinnonBuck
Copy link
Member

@MackinnonBuck MackinnonBuck commented Oct 31, 2024

Adds a new package Microsoft.AspNetCore.Assets.Pack (final package name open for discussion), which includes Blazor framework files as static web assets. A follow-up change in the SDK will add an implicit reference to this package in any Blazor project targeting .NET 10 or later.

This change means that blazor.*.js files will get compressed and fingerprinted automatically.

Fixes #58783

@javiercn
Copy link
Member

javiercn commented Nov 5, 2024

Microsoft.AspNetCore.Assets.Pack

Haven't looked at the PR yet, but we should probably name it in a way that is related to the framework reference and include Internal in some way. Microsoft.AspNetCore.App.Internal.Assets

It might also be interesting if we find a way of precluding explicit consumption through a package reference (we can have MSBuild logic to potentially detect that scenario).

<Description>ASP.NET Core static framework assets</Description>
<PackageId>Microsoft.AspNetCore.Assets.Pack</PackageId>
<IsPackable>true</IsPackable>
<OutputType>Library</OutputType>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why library?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not? This is not producing any exe/dll

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wanted to make sure it's intentional, I don't know off the top of my head if this controls any behavior we care about

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's conceptually a library

@MackinnonBuck MackinnonBuck force-pushed the mbuck/js-assets-package branch from d65dd82 to fa5f52d Compare November 7, 2024 00:40
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Nov 19, 2024
@MackinnonBuck MackinnonBuck merged commit 5493b41 into main Nov 20, 2024
27 checks passed
@MackinnonBuck MackinnonBuck deleted the mbuck/js-assets-package branch November 20, 2024 22:43
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview1 milestone Nov 20, 2024
Comment on lines +46 to +48
<Error
Condition="'@(_MissingBlazorJSFile)' != ''"
Text="'%(_MissingBlazorJSFile.Identity)' does not exist. Run 'npm run build' in the repo root to generate the file." />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having troubles getting this to build inside the VMR. Don't we need something similar to

<!-- blazor.webview.js should exist after eng/Npm.Workspace.nodeproj builds. Fall back if not. -->
<Target Name="_CheckBlazorWebViewJSPath" AfterTargets="ResolveProjectReferences" Condition=" !EXISTS('$(BlazorWebViewJSFile)') ">
<Warning Text="'$(BlazorWebViewJSFile)' does not exist. Falling back to checked-in copy." />
<PropertyGroup>
<BlazorWebViewJSFile>..\..\..\Web.JS\dist\Release\$(BlazorWebViewJSFilename)</BlazorWebViewJSFile>
</PropertyGroup>
</Target>
as a fallback?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK my issue with building this inside the VMR is unrelated to this change. But I wonder if a fallback should still get added as the other project has it.

@ViktorHofer
Copy link
Member

So with this change I can't build the repo anymore if I don't have nodejs installed. Is that intentional?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop embedding JS files in Endpoints and Server assemblies
4 participants