unoplatform / Uno.Wasm.Bootstrap

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

Failed to generate AOT layout after adding dependency #515

Open petertiedemann opened 2 years ago

petertiedemann commented 2 years ago

I have a small sample "app" where I am testing the ability to execute some of our libraries in WASM. Without any dependencies the project compiles okay using InterpreterAndAOT. When I add our library as a nuget package (targeting net60 and netstandard20), it works with Interpreter. However with InterpreterAndAOT I get "Failed to generate AOT layout after adding dependency".

I tried to follow the troubleshooting docs, and in the binlog I noticed this occurring several times:

Runtime critical type System.Object not found

I don't see anything in the log that would explain this (I mean there are trim analysis warnings and a few unrelated errors such as ILLink: error IL1009: Assembly reference 'System.Threading.AccessControl' could not be resolved).

I can probably share the binlog if needed, but need to check it for sensitive data first.

Does this kind of error indicate a bug (and if so, in mono-wasm or in the bootstrapper?) or simply a setup issue? It was not clear to me from the error message.

EDIT: Forgot to include version used:Uno.Wasm.Bootstrap 3.3.1 and the app project is .NET 6.0 while the dependencies are .netstandard 2.0

MartinWelsch commented 1 year ago

I just had the same issue on the same versions. It turned out that somewhere (not in my project .csproj) a reference to Microsoft.Windows.Compatibility with version 5.0.0 was added. After adding <PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" /> to my .csproj file, the linker found all references.

Stragely enough this issue only appeared when building with dotnet build and not when hitting "build project" in Rider.

jeromelaban commented 1 year ago

It turned out that somewhere (not in my project .csproj) a reference to Microsoft.Windows.Compatibility with version 5.0.0 was added.

Note that this behavior will be adjusted when net7.0 is used by the project when: https://github.com/unoplatform/Uno.Wasm.Bootstrap/blob/a40b560a38c52f25130a2a9499974e2a7ca998ac/src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets#L85 will be set to false by default. This property can currently be set when using bootstrapper 4.0-dev bits.