dotnet / dotnet/sdk

dotnet command fails when both x64 and x86 SDKs are installed on Windows

Open
#49,907 2 comments 0 reactions 0 assignees View on GitHub
Area-CLI untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Description

Bug Description
When both the x64 and x86 .NET SDKs are installed on a Windows system, the dotnet command becomes non-functional in any terminal (PowerShell, CMD). Executing any dotnet command (e.g., dotnet --list-sdks, dotnet --info) produces no output and returns immediately. This also prevents Visual Studio from creating new .NET projects.
The issue appears to be caused by a conflict between the dotnet.exe host executables in the two installation paths (C:\Program Files\dotnet\ and C:\Program Files (x86)\dotnet\), which are both present in the system's PATH environment variable.

### Reproduction Steps

On a Windows machine, install the x64 .NET SDK.
Verify that dotnet --info works correctly.
Install the x86 .NET SDK.
Open a new terminal and run dotnet --list-sdks.

### Expected behavior

The dotnet command should execute and list the installed SDKs, correctly resolving which host to use or providing a clear error message.
Actual Behavior

### Actual behavior

The command produces no output and exits immediately.
Example from PowerShell:
Generated powershell
PS C:\Users\someuser> dotnet --list-sdks
PS C:\Users\someuser>

### Regression?

I am not sure if this is a regression, as I have not tested this scenario on previous .NET versions.

### Known Workarounds

The issue can be resolved by renaming the x86 version of the host executable.
Navigate to the x86 installation folder: C:\Program Files (x86)\dotnet\
Rename dotnet.exe to dotnet.exe.bak.
Open a new terminal. The dotnet command now correctly points to the x64 version and functions as expected.
After applying the workaround:

Generated powershell
PS C:\Users\someuser> dotnet --list-sdks
9.0.302 [C:\Program Files\dotnet\sdk]
PS C:\Users\someuser>

### Impact

This bug completely blocks the use of the dotnet CLI for any developer who needs both x64 and x86 SDKs installed simultaneously. This is a common requirement for projects that need to target both architectures. The impact is high for affected users, as it prevents building, running, and testing applications from the command line and can also break IDE functionality like project creation in Visual Studio.

### Configuration

.NET SDK Version: 9.0.302 (both x64 and x86)
OS: Windows 11 24h2

### Other information

https://blog.csdn.net/weixin_43147423/article/details/131213232
A bug that has existed since at least 2023.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.