unoplatform / Uno.Wasm.Bootstrap

A simple nuget package to run C# code in a WASM-compatible browser
Other
364 stars 57 forks source link

`StaticWebAssetsResolverTask` appears to be broken starting with .NET 9 SDK Preview 4 #854

Closed Youssef1313 closed 2 months ago

Youssef1313 commented 2 months ago

PR https://github.com/dotnet/sdk/pull/39405 was merged into Preview 4 and has broke our task.

Our task has StaticWebAsset output which is now missing Fingerprint and Integrity metadata, causing failures like:

/__t/dotnet/sdk/9.0.100-preview.4.24267.66/Sdks/Microsoft.NET.Sdk.StaticWebAssets/targets/Microsoft.NET.Sdk.StaticWebAssets.Compression.targets(280,5): error MSB4018: The "ResolveCompressedAssets" task failed unexpectedly.
System.InvalidOperationException: Fingerprint for '/__w/1/s/src/SamplesApp/SamplesApp.Wasm/bin/Release/net8.0/dist/index.html' is not defined.
   at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.Validate()
   at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.FromTaskItem(ITaskItem item)
   at System.Linq.Enumerable.ArraySelectIterator`2.Fill(ReadOnlySpan`1 source, Span`1 destination, Func`2 func)
   at System.Linq.Enumerable.ArraySelectIterator`2.ToArray()
   at Microsoft.AspNetCore.StaticWebAssets.Tasks.ResolveCompressedAssets.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(TaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/__w/1/s/src/SamplesApp/SamplesApp.Wasm/SamplesApp.Wasm.csproj]

Here is our currently defined metadata:

https://github.com/unoplatform/Uno.Wasm.Bootstrap/blob/72de499bc1f8cdba304ad4b156c259e0833398f7/src/Uno.Wasm.Bootstrap/StaticWebAssetsResolverTask.cs#L76-L84

Here is what .NET expects:

https://github.com/dotnet/sdk/blob/d665fdf4adeb9b4b6b874e324ffa9a8f76c6edc9/src/StaticWebAssetsSdk/Tasks/Data/StaticWebAsset.cs#L283-L301

The Fingerprint and Identity ones are required:

https://github.com/dotnet/sdk/blob/d665fdf4adeb9b4b6b874e324ffa9a8f76c6edc9/src/StaticWebAssetsSdk/Tasks/Data/StaticWebAsset.cs#L383-L391

Youssef1313 commented 2 months ago

cc @jeromelaban @ebariche

This one is quite important I think?

Youssef1313 commented 2 months ago

NOTE:

In BuildDist, we are doing this:

        <ItemGroup>
            <StaticWebAsset Remove="@(StaticWebAsset)" />
        </ItemGroup>

        <StaticWebAssetsResolverTask_v141bdf179d88790116104b9a8c602bc694813ebc
            WebAppBasePath="$(WasmShellWebAppBasePath)"
            DistPath="$(WasmShellOutputDistPath)"
            AssemblyName="$(AssemblyName)"
            ProjectDirectory="$(MSBuildProjectDirectory)">
            <Output TaskParameter="StaticWebAsset" ItemName="StaticWebAsset" />
        </StaticWebAssetsResolverTask_v141bdf179d88790116104b9a8c602bc694813ebc>

The removed StaticWebAsset has the correct metadata, but then StaticWebAssetsResolverTask adds StaticWebAsset back with missing Fingerprint and Identity

Youssef1313 commented 2 months ago

And this is how it should be calculated:

https://github.com/dotnet/sdk/blob/cc17704acfbee4b2ef49a82aa6f65aaa9cafffef/src/StaticWebAssetsSdk/Tasks/Data/StaticWebAsset.cs#L233-L248