C
C#2w ago
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
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
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
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
7 Replies
reflectronic
reflectronic2w ago
yes, it's a bug in the way Native AOT finds the tools unfortunately, it won't detect VS 2026 one way to fix is is to target .NET 10 instead another way to fix it is to wait until next month when the fix will be made available for .NET 9 you can also fix it by going into your NuGet global pakcages cache, and editing this file
microsoft.dotnet.ilcompiler\9.0.11\build\findvcvarsall.bat
microsoft.dotnet.ilcompiler\9.0.11\build\findvcvarsall.bat
to remove this line:
-version [16^,18^) ^
-version [16^,18^) ^
.
Anar
AnarOP2w ago
hey, I actually came across you while searching if this question had already been asked before in this server https://discord.com/channels/143867839282020352/169726586931773440/1130516073989558352 (year 2023) I was hoping so much you'd still be active and see my post 😄
MODiX
MODiX2w ago
reflectronic
you need the Windows SDK and the regular MSVC build tools
Quoted by
<@751125875164053586> from #help-0 (click here)
React with ❌ to remove this embed.
Anar
AnarOP2w ago
I see, so I wasn't going crazy LOL I switched to dotnet 10 right now and it works! guess I'll just upgrade the project and keep it thank you very much imma close the post once you're back online
reflectronic
reflectronic2w ago
glad it's working :)
Anar
AnarOP2w ago
$close
MODiX
MODiX2w ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?