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

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

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).

<!-- The package doesn't produce any lib or ref assemblies -->
<NoWarn>$(NoWarn);NU5128</NoWarn>

<StaticWebAssetBasePath>_framework</StaticWebAssetBasePath>
Copy link
Member

Choose a reason for hiding this comment

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

We should not set the base path to _framework it should be / and the relative paths on the assets to include _framework.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, this should be $(StaticWebAsetBasePath), if the user sets the base path in their project, the assets should be located in their app base path, not anywhere else.

Copy link
Member Author

Choose a reason for hiding this comment

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

Would this require that we move most of the static web asset generation into the build/*.targets file so we get insight into the props of the consuming project? Or is there another way you had in mind that we'd achieve this?

Copy link
Member

Choose a reason for hiding this comment

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

We don't really need to move the logic there, we can "escape" the value so that it ends up as $(StaticWebAsetBasePath) in the file.

Same with the $(SourceId), we can use escaping for now

<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

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop embedding JS files in Endpoints and Server assemblies
3 participants