C#C
C#4mo ago
15 replies
Anar

✅ "Platform linker not found." error with NativeAOT (Visual Studio Insiders)

I want to compile with NativeAOT:
* I added
<PublishAot>true</PublishAot>
property to my .csproj file
* I am not using reflection or any other feature that would break my app
* I have the "Desktop development with C++" workload installed
* I open "x64 Native Tools Command Prompt for VS Insiders" and
where link
command does seem to print a correct path
C:\Program Files\Microsoft Visual Studio\18\Insiders\VC\Tools\MSVC\14.50.35717\bin\Hostx64\x64\link.exe


I am using this command on my Windows machine:
dotnet publish ./MyProject.csproj -c Release -r win-x64 --self-contained true -p:PublishAot=true

However, I get this error in the end:
Restore complete (0.3s)
  RdcEngine net9.0 succeeded (0.1s) → RdcEngine\bin\Release\net9.0\RdcEngine.dll
  RdcCli net9.0 win-x64 failed with 1 error(s) (0.5s) → RdcCli\bin\Release\net9.0\win-x64\rdc.dll
    C:\Users\Legion\.nuget\packages\microsoft.dotnet.ilcompiler\9.0.11\build\Microsoft.NETCore.Native.Windows.targets(138,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.

Build failed with 1 error(s) in 1.4s


Why can't it find the linker? What am I missing?

It used to work back when I was using Visual Studio 2022, which might be a coincidence but I suspect it is to do with the IDE itself
Was this page helpful?