dotnet / linker

387 stars 134 forks source link

TrimmerRootAssembly results in incoherent trimming and hence integrity check error #3240

Closed zorgoz closed 6 months ago

zorgoz commented 6 months ago

My actual scenario involves this library, but looks not to be related. Still, I have examples for this, hence I am using it as a reference.

Steps to reproduce:

  1. Create new hosted asp.net Blazor WebaAssembyl project
  2. Add "Blazicons.MaterialDesignIcons" library reference to the client project
  3. Use one of the icons on a page.
  4. Add timming opt-out to csproj (based on this docs page):
    <ItemGroup>
    <TrimmerRootAssembly Include="Blazicons.MaterialDesignIcons" />
    </ItemGroup>
  5. Create folder publish profile (Release, .net 7, portable)
  6. Observe \wwwroot\_framework (the uncompressed file is not trimmed, the compressed ones are) Enabled 6 . Try to run the published project. You will get:

    Failed to find a valid digest in the 'integrity' attribute for resource 'https://.../_framework/Blazicons.MaterialDesignIcons.dll' with computed SHA-256 integrity 'gMXbZ3OfWdujY73B/l1KFNoubyP8nqgEYJ/OZjVnvaM='. The resource has been blocked.

  7. If you download the file directly, you will get the compressed one.
  8. Remove 4. from csproj.
  9. Republish and observe folder (all are trimmed coherently): Disabled
  10. Reload page. No error this time.

dotnet --info

zorgoz commented 6 months ago

Reopened here: https://github.com/dotnet/runtime/issues/96620