Repository navigation
dotnet publish -c Release fail with <RunAOTCompilation>true</RunAOTCompilation> and <BlazorWebAssemblyLazyLoad #60479
Copy link
Copy link
Closed
Labels
Milestone
Description
Description
If we want to compile a Blazor project with AOT and lazy loading the command dotnet publish -c Release fail with error :
error BLAZORSDK1001: Unable to find '[lazy load assembly name].dll' to be lazy loaded later. Confirm that project or package references are included and the reference is used in the project.
Reproduction Steps
- Create a blazor wasm project
- Create a razor class library project
- Add a project reference to for the razor class library project to the blazor wasm project
- Add a BlazorWebAssemblyLazyLoad instruction for the razor class library assembly in the blazor wasm project
- Add true in the blazor wasm project
- try to publish the blazor wasm project with
dotnet publish -c Release
ex:
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RunAOTCompilation>true</RunAOTCompilation>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.0-rc.2.21480.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.0-rc.2.21480.10" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="6.0.0-rc.2.21480.10" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RazorClassLibrary\RazorClassLibrary.csproj" />
</ItemGroup>
<ItemGroup>
<BlazorWebAssemblyLazyLoad Include="RazorClassLibrary.dll" />
</ItemGroup>
</Project>Expected behavior
The publish command should run without error
Actual behavior
The publish command fail with :
error BLAZORSDK1001: Unable to find '[razor class library name].dll' to be lazy loaded later. Confirm that project or package references are included and the reference is used in the project.
Regression?
No response
Known Workarounds
No response
Configuration
❯ dotnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.100-rc.2.21505.57
Commit: ab39070116
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.100-rc.2.21505.57\
Host (useful for support):
Version: 6.0.0-rc.2.21480.5
Commit: 6b11d64e7e
.NET SDKs installed:
1.1.14 [C:\Program Files\dotnet\sdk]
2.2.207 [C:\Program Files\dotnet\sdk]
3.1.402 [C:\Program Files\dotnet\sdk]
5.0.205 [C:\Program Files\dotnet\sdk]
5.0.402 [C:\Program Files\dotnet\sdk]
6.0.100-rc.2.21505.57 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.0-rc.2.21480.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.0-rc.2.21480.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.0-rc.2.21501.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-downloadOther information
No response
Activity
pranavkm commentedon Oct 15, 2021
@radical it looks related to #60274. I have a binlog at "\prkrishn-foo\share\msbuild.binlog" in case it helps, but it's fairly trivial to reproduce this with a regular blazor-wasm app.
Publish runs twice
and in the first one a bunch of MSBuild properties aren't resolved which results in this error:
First publish:

^ Notice Resources is missing
Second publish:

The first one is kicked off by
WasmNestedPublishApp. More worrying is that it's sufficient to have the tool installed (without required AOT compilation) to run in to this issue:radical commentedon Oct 15, 2021
That one is failing with
The command "emcc --version" exited with code 1., and seems unrelated.This is my understanding of what's happening here:
For the nested publish, we essentially run
Publishtarget, and then the wasm native targets runduring the
Publishpart of it:a. we get to
ProcessPublishFilesForBlazor, which currently we skip for the nested publish case ($(WasmBuildingForNestedPublish))@(StaticWebAsset), when runb. Then we get to
GeneratePublishBlazorBootJson, which fails because it doesn't have theStaticWebAssetscorrectly populated, and thus can't find the lazy loaded assemblyPlease correct me if I didn't that right. I don't really understand the static web assets part.
To fix this, I tried removing the condition on ProcessPublishFilesForBlazor so it would run for nested publish also.
@(WasmAssembliesToBundle)is emptyThat seems to be because
ProcessPublishFilesForBlazorremoves items from ResolveFileToPublish_GatherWasmFilesForPublishto fail as it depends on@(ResolvedFileToPublish)to populate@(WasmAssembliesToBundle)If this line of thinking is correct, then maybe we can instead of
@(StaticWebAsset):I'm not sure if this is the correct fix or not. @javiercn thoughts?
Our blazorwasm tests fail with this though, because there are more than one
dotnet*jsfiles in the publish folder:For future (7.0) work, the targets can be reworked a bit to reduce the amount of work we do in the nested publish, and better integrate it.
cc @lewing
srpeirce commentedon Oct 15, 2021
This is duplicate to this issue? dotnet/aspnetcore#37570
The linked issue has same issue but AOT is
disabled. It is usingwasm-tools.Minimal example linked in the project if helpful.
pranavkm commentedon Oct 15, 2021
@srpeirce the presence of the wasm-tools is sufficient to trigger the same code that appears as part of AOT.
pranavkm commentedon Oct 15, 2021
@radical transferring this over to you.
[release/6.0.1xx][blazorwasm] Fix publishing project with lazy loaded…
radical commentedon Oct 19, 2021
Fixed by dotnet/sdk#22145 . I will port this to
mainalso.