Ahead-of-Time compilation is not supported for the target runtime identifier ‘win-x86’

A few days ago, I encountered a problem on my Windows machine and had to reinstall everything. After reinstalling Visual Studio and attempting to compile my project, I started receiving the following error when trying to perform Ahead-of-Time (AOT) compilation with the following command:

dotnet publish -r win-x86 -c Release

C:Program Filesdotnetsdk8.0.400SdksMicrosoft.NET.SdktargetsMicrosoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error NETSDK1203: Ahead-of-Time compilation is not supported for the target runtime identifier 'win-x86'

Before the crash and the subsequent reinstall, I was able to successfully publish my app as native with AOT. I can still compile into x86 release without problems. Since the crash, I haven’t altered any project configurations.

Details:

  • App Type: Windows console application

  • Current .NET SDK Version: 8.0.400

  • CSProj File:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <PublishAot>true</PublishAot>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <InvariantGlobalization>true</InvariantGlobalization>
    <Platforms>AnyCPU;x64;x86</Platforms>
    <ApplicationManifest>app.manifest</ApplicationManifest>
    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
    <TrimMode>partial</TrimMode>
    <AssemblyName>MyApp</AssemblyName>
    <PublishAot>true</PublishAot>
  </PropertyGroup>

  

  ...my packages

</Project>

What steps can I take to resolve this issue and re-enable AOT compilation for my project?
Thanks!

What i did:

  1. I installed from scratch

    – .NET development for desktop
    – Development of windows applications

  2. Opened my Console app and tried to execute
    dotnet publish -r win-x86 -c Release

    I expected a normal x86 AOT compilation as it used to work.

4

Beginning with .NET 8, according to the Native AOT deployment documentation, on Windows you must install the following:

Visual Studio 2022, including the Desktop development with C++ workload with all default components.

If you did not do that when you installed Visual Studio 2022, follow the instructions from Modify Visual Studio workloads, components, and language packs:

  1. Find and rerun the installer. If already installed, it’s likely at

    C:Program Files (x86)Microsoft Visual StudioInstallersetup.exe

  2. From the list of installed versions of Visual Studio, pick the version of Visual Studio 2022 you want to modify, then pick “Modify”.

  3. From the “Modifying – Visual Studio 2022” dialog, pick “Workloads” and then “Desktop development with c++”. You may need to scroll down to see it:

    From your question it appears you picked “.NET desktop development” which is not sufficient.

  4. Finish up the installer and restart.

Once installed you should be able to publish native builds on Windows. But do note the following Platform/architecture restrictions:

Platform Supported Architecture
Windows x64, Arm64

Thus you cannot publish a native x86 (32-bit) build, you can only publish a native x64 or arm64 build:

dotnet publish -r win-x64 -c Release

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật