dotnet / dotnet/dotnet-docker

windows image (nanoserver, windowsservercore) with Native AOT support

Open
#6,874 1 comment 0 reactions 1 assignee Claimed by @lbussell View on GitHub
area-dockerfiles
Dominant language
Dockerfile
Stars
4.9k
Forks
2k
Avg merge
1d 14h
Merged PRs (30d)
26

Description

### Describe the Problem

I am trying to publish a console application for windows using native AOT. However when using the nanoserver image it fails with the following:

```
C:\Users\ContainerUser\.nuget\packages\microsoft.dotnet.ilcompiler\10.0.1\build\Microsoft.NETCore.Native.Windows.targets(142,5): error : Platform linker not found. Ensure you have all the required prerequisites documented at https://aka.ms/nativeaot-prerequisites, in particular the Desktop Development for C++ workload in Visual Studio. For ARM64 development also install C++ ARM64 build tools. [C:\builds\launcher\Launcher.csproj]
```

### Describe the Solution

I think it would be good to have **nanoserver image, with native AOT support**, like the new linux-aot images.

Im personally not sure how doable this is, since the documentation only states "Visual Studio 2022 or later, including the Desktop development with C++ workload with all default components.". I could not find a workload via the dotnet workload command that would be fitting.

### Additional Context

Nanoserver Image Used: `mcr.microsoft.com/dotnet/sdk:10.0-nanoserver-ltsc2025`
Build command: `dotnet publish -r win-x64 Launcher.csproj -o ./bin`
Native AOT enabled in .csproj

EDIT:
servercore image also fails with the same reason, I previously assumed it would work due to the documentation stating that only the nano image isnt preconfigured for it.
Workaround, use the servercore image and install the build tools manually.
Do note that this uses a lot of disk, I assumed thats why its not included in any of the normal images...
```
- powershell -Command "Invoke-WebRequest -Uri https://aka.ms/vs/17/release/vs_buildtools.exe -OutFile vs_buildtools.exe"
- powershell -Command "Start-Process -FilePath .\vs_buildtools.exe -ArgumentList '--quiet --norestart --wait --nocache --installPath C:\BuildTools --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows11SDK.26100' -Wait"
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.