Error publishing Blazor Webassembly with AOT (.Net 8.0) - Error : Precompiling failed for "aot-instances.dll" with exit code 1. Can not open image
Asked Answered
M

3

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.

Mccusker answered 6/12, 2023 at 20:59 Comment(0)
U
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

Upheaval answered 21/5 at 21:14 Comment(1)
See here: github.com/dotnet/runtime/issues/103293 As far as I know, it was not fixed.Puff
E
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.

Eulogist answered 9/5 at 17:12 Comment(0)
E
-4

I changed this line in the project file:

<RunAOTCompilation>true</RunAOTCompilation>

to

<RunAOTCompilation>false</RunAOTCompilation>

and had a successful publish.

Ebon answered 4/1 at 7:36 Comment(4)
I realized I could turn AOT off and it would publish, but I wanted to publish with AOT.Mccusker
I have the same issue, I have dev building without AOT not problem, I need releases to be AOT.Hoopoe
@Mccusker 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.Bonnes
Still getting the same error locally and to Azure.Mccusker

© 2022 - 2024 — McMap. All rights reserved.