Description
Publishing a NativeAOT app on Windows fails at the native link step with MSB3073 (exit code 123) when the environment variable NoDefaultCurrentDirectoryInExePath is set.
The cmd error message 'vswhere.exe' is not recognized ... gets embedded into the linker command line.
I hit this with Claude Code, which sets NoDefaultCurrentDirectoryInExePath=1 for every shell it spawns: a NativeAOT dotnet publish run from a Claude Code session fails, while the same command succeeds from a plain cmd.exe. The repro below does not need Claude Code — setting the variable manually is sufficient.
Reproduction Steps
On Windows, with the Visual Studio C++ build tools installed (VS 2026):
dotnet new console --aot
set NoDefaultCurrentDirectoryInExePath=1
dotnet publish
Expected behavior
The publish succeeds. The C++ toolchain is actually found correctly.
Actual behavior
Restore complete (0.2s)
NativeAotErrorTest net10.0 win-x64 failed with 1 error(s) (2.6s) → bin\Release\net10.0\win-x64\NativeAotErrorTest.dll
C:\Users\user\.nuget\packages\microsoft.dotnet.ilcompiler\10.0.9\build\Microsoft.NETCore.Native.targets(396,5): error MSB3073: The command ""'vswhere.exe' is not recognized as an internal or external command, operable program or batch file.;C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\bin\Hostx64\x64\link.exe" @"obj\Release\net10.0\win-x64\native\link.rsp"" exited with code 123.
Build failed with 1 error(s) in 3.1s
Regression?
Not as far as I know.
Known Workarounds
Unset the variable for the build: set NoDefaultCurrentDirectoryInExePath= before dotnet publish.
Configuration
- .NET SDK 10.0.301, Microsoft.DotNet.ILCompiler 10.0.9
- Windows 11 Pro (10.0.26200), x64
- VS Community 2026 18.5.3 (MSVC 14.50.35717)
Other information
No response
Description
Publishing a NativeAOT app on Windows fails at the native link step with
MSB3073(exit code 123) when the environment variableNoDefaultCurrentDirectoryInExePathis set.The cmd error message
'vswhere.exe' is not recognized ...gets embedded into the linker command line.I hit this with Claude Code, which sets
NoDefaultCurrentDirectoryInExePath=1for every shell it spawns: a NativeAOTdotnet publishrun from a Claude Code session fails, while the same command succeeds from a plaincmd.exe. The repro below does not need Claude Code — setting the variable manually is sufficient.Reproduction Steps
On Windows, with the Visual Studio C++ build tools installed (VS 2026):
Expected behavior
The publish succeeds. The C++ toolchain is actually found correctly.
Actual behavior
Regression?
Not as far as I know.
Known Workarounds
Unset the variable for the build:
set NoDefaultCurrentDirectoryInExePath=beforedotnet publish.Configuration
Other information
No response