-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Using Microsoft.AspNetCore.ClientAssets on a RCL doesn't work with the .NET 9 SDK even if i target net8.0 on pack.
While ClientAssets are outputting files (correctly in my opinion) im getting the following error:
- Create net8.0 RCL without wwwroot
- Add Microsoft.AspNetCore.ClientAssets
- Pack fails now
Restore complete (0,2s)
MyProject failed with 1 error(s) (4,2s) → bin\Release\net8.0\MyProject.dll
C:\Program Files\dotnet\sdk\9.0.303\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(221,5): error NU5019: File not found: 'D:\MyProject\obj\Release\net8.0\staticwebassets\msbuild.MyProject.Microsoft.AspNetCore.StaticWebAssetEndpoints.props'.
You can workaround this issue in net8.0 target framework projects by adding one single file (ive just added an empty file underscore without content "_"). Because net8 is not yet using the new StaticAssets pipeline this would work
By doing the same as above while targeting net9.0 this will not work anymore (and fails on build instead of later in pack)
StaticAssetsClientAssets failed with 1 error(s) and 1 warning(s) (5,8s)
C:\Program Files\dotnet\sdk\9.0.303\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.Compression.targets(248,5): warning : Endpoints not found for related asset: D:\MyProject\obj\Debug\net9.0\clientassets\hello.js
C:\Program Files\dotnet\sdk\9.0.303\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.Compression.targets(248,5): error MSB4018:
The "ApplyCompressionNegotiation" task failed unexpectedly.
System.InvalidOperationException: Endpoints not found for related asset: D:\MyProject\obj\Debug\net9.0\clientassets\hello.js
at Microsoft.AspNetCore.StaticWebAssets.Tasks.ApplyCompressionNegotiation.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(TaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
This happened because we upgraded our .NET SDK on the build machine to the newest release (both 8 & 9) i cannot exactly say which version switch caused the issue.
This could also be an issue with the .NET SDK but because Microsoft.AspNetCore.ClientAssets is experimental im placing this issue here.
We could switch to an alternative. But as far as i know we are still waiting for #38445
Expected Behavior
We need a way to still use webpack to build our assets and include them in the RCL. (Without building them manually and copying to wwwroot)
Steps To Reproduce
You can find a sample here:
https://github.com/dp-sgr/StaticAssetsClientAssetsIssue
Exceptions (if any)
No response
.NET Version
9.0.303
Anything else?
Installed SDK's:
8.0.412
9.0.303