dotnet / core

.NET news, announcements, release notes, and more!
https://dot.net
MIT License
21.01k stars 4.91k forks source link

[.NET Tutorial]: dot net 8 web api aot compilation error #8649

Closed jdurnil closed 9 months ago

jdurnil commented 1 year ago

URL

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/aot/native-aot-tutorial?view=aspnetcore-8.0&tabs=netcore-cli

Operating system

windows 10

More information about your system

x64, visual studio 2022 preview with .net 8 preview 6 installed and .net 8 sdk latest preview. Visual Studio 2022 installed with asp.net and c++ options

Description

I am trying to just publish the base code when creating a project using dotnet new api --aot -o MyFirstAotWebApi && cd MyFirstAotWebApi

the program runs fine in debug mode then I just do a dotnet publish and get this error MyFirstAotWebApi -> C:\Program Files\no\MyFirstAotWebApi\bin\Release\net8.0\win-x64\MyFirstAotWebApi.dll Generating native code C:\Users\M31926.nuget\packages\microsoft.dotnet.ilcompiler\8.0.0-preview.6.23329.7\build\Microsoft.NETCore.Native .targets(290,5): error MSB3073: The command ""C:\Users\M31926.nuget\packages\runtime.win-x64.microsoft.dotnet.ilcompiler\8.0.0-preview.6.23329.7\tools\ilc" @"obj\Release\net8.0\win-x64\native\MyFirstAotWebApi.ilc.rsp"" exited with code -2147483645. [C:\Program Files\no\MyFirstAotWebApi\MyFirstAotWebApi.csproj]

dotnet --info

.NET SDK: Version: 8.0.100-preview.6.23330.14 Commit: ba97796b8f

Runtime Environment: OS Name: Windows OS Version: 10.0.19044 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\8.0.100-preview.6.23330.14\

.NET workloads installed: There are no installed workloads to display.

Host: Version: 8.0.0-preview.6.23329.7 Architecture: x64 Commit: 5340be2ccc

.NET SDKs installed: 7.0.306 [C:\Program Files\dotnet\sdk] 7.0.400-preview.23330.10 [C:\Program Files\dotnet\sdk] 8.0.100-preview.6.23330.14 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 6.0.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.0-preview.6.23329.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.0-preview.6.23329.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 8.0.0-preview.6.23329.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found: x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables: Not set

global.json file: Not found

Learn more: https://aka.ms/dotnet/info

Download .NET: https://aka.ms/dotnet/download

LakshanF commented 1 year ago

@jdurnil, this is a known issue that we are working towards fixing. NativeAOTapplications build prior to this PR is susceptible to crashes when a client turns on machine wide tracing while using an impacted NativeAOTapplication. Unfortunately, ILC, the ILCompilertool, is a NativeAOTapplication that shows this problem. We are working towards updating ilc.

A common pattern for this issue: If you are debugging VS on a separate process (breakpoint on a HelloWorld for example) in the same machine, and then uses an impacted NativeAOTapplication (ILC gets used when you invoke dotnet publish). VS in this scenario, will send a request to the affected NativeAOT to turn on tracing, which will cause the problem you see in ILC.

A workaround for that scenario would be to stop debugging VS until the application is published.

Sorry for the inconvenience that this problem caused you.

jdurnil commented 1 year ago

hello i was not debugging the app during publish i was getting this message with the app completely stopped. What fixed this issue was to do a dotnet restore on the sample project then it built.

LakshanF commented 1 year ago

Glad that you got unblocked! Let me know if you run into the issue again, and the state of the other programs in the machine. The issue I mentioned above where it impacts ILC can happen when a machine wide tracing is enabled (ETW is turned on machine-wide for example).

jkotas commented 9 months ago

This is fixed in .NET 8 release. Thank you for reporting it!