79599449

Date: 2025-04-30 02:34:35
Score: 2
Natty:
Report link

Finally, I have figured it out.

First thing first, it seems that the VS Installer cannot install the .NET 8 SDK for you anymore, and I had to install the SDK outside it, I downloaded dotnet-sdk-8.0.408-win-x64.exe from Microsoft's site and installed the SDK for VS.

Secondly, the culprit is an accidental copy of dotnet.exe, it was made under C:\Windows\System32, and somehow it is corrupted, for its size is 0 byte. I might have made the copy by accidental drag-and-drop, but I cannot be certain, as it should not be 0 byte in that case. This copy is not supposed to be there, and it caused me seeing the error "This app can't run on your PC" (please refer to the question). On the other hand, I realized that Visual Studio itself does not seem to know the location of dotnet.exe, and when it builds, it only relies on the system variables to find out where it is and execute dotnet.exe, and because there is a copy C:\Windows\System32\dotnet.exe, and C:\Windows\System32 is in the variable Path, VS 2022 simply invokes C:\Windows\System32\dotnet.exe, which caused the error "The SDK 'Microsoft.NET.Sdk' specified could not be found." Looking back the history, the problem started exactly the day when this copy was made.

I used tools like process monitor and the command 'where dotnet' for troubleshooting. In summary, I think Microsoft should improve the error message to be more descriptive.

I want to thank those people who tried to help.

Reasons:
  • Blacklisted phrase (0.5): I cannot
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-1):
  • No code block (0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: VincentZHANG