You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NativeAOT publish fails at link step when NoDefaultCurrentDirectoryInExePath is set #129340
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
setNoDefaultCurrentDirectoryInExePath=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.
Actually, this is "fixed" in .NET 11 already. This is a message generated by vcvarsall.bat that comes with Visual Studio, so #126180 also "fixes" this (it redirects the error from vcvarsall to nul).
So the real reason this doesn't work is because vcvarsall that comes with Visual Studio doesn't work with NoDefaultCurrentDirectoryInExePath. I checked and vcvarsall still configures the environment enough to be workable for our purposes despite the message.
Activity
dotnet-policy-service commentedon Jun 12, 2026
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.
MichalStrehovsky commentedon Jun 15, 2026
This will likely get fixed with #129316 that deletes the problematic batch script, but we should re-check once it merges.
MichalStrehovsky commentedon Jun 16, 2026
Actually, this is "fixed" in .NET 11 already. This is a message generated by vcvarsall.bat that comes with Visual Studio, so #126180 also "fixes" this (it redirects the error from vcvarsall to nul).
So the real reason this doesn't work is because vcvarsall that comes with Visual Studio doesn't work with
NoDefaultCurrentDirectoryInExePath. I checked and vcvarsall still configures the environment enough to be workable for our purposes despite the message.MichalStrehovsky commentedon Jun 24, 2026
Confirmed with the latest builds.