7

Error publishing Blazor Webassembly with AOT (.Net 8.0) - Error : Precompiling failed for ProjectTest\obj\Release\net8.0\wasm\for-publish\aot-in\aot-instances.dll. C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.WebAssembly.Sdk\8.0.0\Sdk\WasmApp.Native.targets(686,5): error : Can not open image ProjectTest\ProjectTest.csproj

It worked with .net 7.0. It fails with .net 8.0.

I ran dotnet workload install wasm-tools, since I got that error first with .net 8.0. Then removed the bin and obj files for the entire solution.

I updated packages from nuget. I updated all the package references to 8.0.0 where applicable in my project file.

3 Answers 3

1

Check that you don't have a space in the path to your project file. It seems there is currently a bug in the AOT compilation:

https://github.com/dotnet/runtime/issues/101055

It should be fixed in the next release (8.0.6)

[Edit] As per the comment below, it is now supposed to be fixed in 8.0.7

Sign up to request clarification or add additional context in comments.

1 Comment

See here: github.com/dotnet/runtime/issues/103293 As far as I know, it was not fixed.
0

I had a similar problem, and it turned out that RunAOTCompilation was defined twice in the same csproj file.

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <RunAOTCompilation>True</RunAOTCompilation>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <RunAOTCompilation>True</RunAOTCompilation>
  </PropertyGroup>

I just had to delete one of these property groups.

I'm not sure how it happened. Probably because, while VS installer was downloading some component required to compile in webassembly, it closed VS automatically. When I opened it again, it asked if I'd like to recover csproj file which was not saved before. I said 'yes' and it probably generated the same setting twice at that moment.

Comments

-4

I changed this line in the project file:

<RunAOTCompilation>true</RunAOTCompilation>

to

<RunAOTCompilation>false</RunAOTCompilation>

and had a successful publish.

4 Comments

I realized I could turn AOT off and it would publish, but I wanted to publish with AOT.
I have the same issue, I have dev building without AOT not problem, I need releases to be AOT.
@purello Have you got the resolution without turning off the AOT? In my case it is working correctly on local environment but fails with ADO Pipeline.
Still getting the same error locally and to Azure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.