Skip to content

Dotnet 10 Blazor web publish - has something changed with lazy loading? #64286

@Stuart88

Description

@Stuart88

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

My Blazor web application has a lot of lazy loading of wasm assemblies, which works fine with dotnet 9

I'm now trying dotnet 10 rc2, and it still works fine when running local debug on my machine.

But when I publish it, the publish output is failing with

..\10.0.0-rc.2.25502.107\build\Microsoft.NET.Sdk.WebAssembly.Browser.targets(804,5): 

Error BLAZORSDK1001: Unable to find

Web.Client.Portal.wasm;
BlazorPro.BlazorSize.wasm;
Cropper.Blazor.wasm;
zxcvbn-core.wasm;
System.Web.HttpUtility.wasm;
System.Runtime.Serialization.Primitives.wasm;
CsvHelper.wasm;
zxing.wasm;
Microsoft.CSharp.wasm;
System.Data.Common.wasm;
System.Diagnostics.TraceSource.wasm;
System.Drawing.wasm;
System.Drawing.Primitives.wasm;
System.Runtime.Serialization.Formatters.wasm'

to be lazy loaded later. 
Confirm that project or package references are included and the reference is used in the project.

Does something need to change with the way the publish instructions are given?

The publish profile looks like this:

<Project>
  <PropertyGroup>
    <DeleteExistingFiles>false</DeleteExistingFiles>
    <ExcludeApp_Data>false</ExcludeApp_Data>
    <LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
    <LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <PublishProvider>FileSystem</PublishProvider>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <_TargetId>Folder</_TargetId>
    <SiteUrlToLaunchAfterPublish />
    <TargetFramework>net10.0</TargetFramework>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <ProjectGuid>fd2de88c-73e3-4302-8ded-df942e424017</ProjectGuid>
    <SelfContained>false</SelfContained>
  </PropertyGroup>
</Project>

And this is how my Web.Client csproj looks, with the setup for lazy loading (and worked fine when publishing with dotnet 9).

<PropertyGroup>
  <TargetFramework>net10.0</TargetFramework>
  <ImplicitUsings>enable</ImplicitUsings>
  <Nullable>enable</Nullable>
  <NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
  <StaticWebAssetProjectMode>Default</StaticWebAssetProjectMode>
  <EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup>

<PropertyGroup>
  <PublishTrimmed>true</PublishTrimmed>
  <BlazorWebAssemblyLoadAllGlobalizationData>false</BlazorWebAssemblyLoadAllGlobalizationData>
  <InvariantGlobalization>true</InvariantGlobalization>
  <TrimSymbols>true</TrimSymbols>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'DevDeploy'">
  <PublishTrimmed>false</PublishTrimmed>
  <BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
  <InvariantGlobalization>false</InvariantGlobalization>
  <TrimSymbols>false</TrimSymbols>
</PropertyGroup>


<ItemGroup>
  <PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
  <PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="8.2.5" />
  <PackageReference Include="Cropper.Blazor" Version="1.4.2" />
  <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.0-rc.2.25502.107" />
  <PackageReference Include="MudBlazor" Version="8.14.0" />
  <PackageReference Include="zxcvbn-core" Version="7.0.92" />
  <PackageReference Include="BlazorPro.BlazorSize" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
  <BlazorWebAssemblyLazyLoad Include="Web.Client.Portal.wasm"  />
  <BlazorWebAssemblyLazyLoad Include="BlazorPro.BlazorSize.wasm" />
  <BlazorWebAssemblyLazyLoad Include="Cropper.Blazor.wasm" />
  <BlazorWebAssemblyLazyLoad Include="zxcvbn-core.wasm" />
  <BlazorWebAssemblyLazyLoad Include="System.Web.HttpUtility.wasm" />
  <BlazorWebAssemblyLazyLoad Include="System.Runtime.Serialization.Primitives.wasm" />


  <!--
  These are not used anywhere but are internally created during publish
  Tried aggressive trimming but it became messy due to various items being referenced via reflection. 
  Discarding via lazy loading is easier to manage.
  -->
  <BlazorWebAssemblyLazyLoad Include="CsvHelper.wasm" />
  <BlazorWebAssemblyLazyLoad Include="zxing.wasm" />
  <BlazorWebAssemblyLazyLoad Include="Microsoft.CSharp.wasm" />
  <BlazorWebAssemblyLazyLoad Include="System.Data.Common.wasm" />
  <BlazorWebAssemblyLazyLoad Include="System.Diagnostics.TraceSource.wasm" />
  <BlazorWebAssemblyLazyLoad Include="System.Drawing.wasm" />
  <BlazorWebAssemblyLazyLoad Include="System.Drawing.Primitives.wasm" />
  <BlazorWebAssemblyLazyLoad Include="System.Runtime.Serialization.Formatters.wasm" />
</ItemGroup>
  
<ItemGroup>
  <TrimmerRootAssembly Include="Web.Client.Portal" />
  <TrimmerRootAssembly Include="BlazorPro.BlazorSize" />
  <TrimmerRootAssembly Include="Cropper.Blazor" />
  <TrimmerRootAssembly Include="zxcvbn-core" />
</ItemGroup>

<ItemGroup>
  <ProjectReference Include="..\..\Shared\Shared.csproj" />
  <ProjectReference Include="..\..\Web.Client.Portal\Web.Client.Portal.csproj" />
  <ProjectReference Include="..\..\Web.Client.Shared\Web.Client.Common.csproj" />
</ItemGroup>

The same failure occurs whether I publish as debug or release.

Thanks

Expected Behavior

dotnet publish should work

Steps To Reproduce

No response

Exceptions (if any)

..\10.0.0-rc.2.25502.107\build\Microsoft.NET.Sdk.WebAssembly.Browser.targets(804,5): 

Error BLAZORSDK1001: Unable to find

Web.Client.Portal.wasm;
BlazorPro.BlazorSize.wasm;
Cropper.Blazor.wasm;
zxcvbn-core.wasm;
System.Web.HttpUtility.wasm;
System.Runtime.Serialization.Primitives.wasm;
CsvHelper.wasm;
zxing.wasm;
Microsoft.CSharp.wasm;
System.Data.Common.wasm;
System.Diagnostics.TraceSource.wasm;
System.Drawing.wasm;
System.Drawing.Primitives.wasm;
System.Runtime.Serialization.Formatters.wasm'

to be lazy loaded later. 
Confirm that project or package references are included and the reference is used in the project.

.NET Version

10 RC2

Metadata

Metadata

Assignees

Labels

Needs: Attention 👋This issue needs the attention of a contributor, typically because the OP has provided an update.area-blazorIncludes: Blazor, Razor Components

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions