Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Solution explorer says "A compatible .Net SDK was not found" #194

Closed
y-chen opened this issue Jun 22, 2023 · 9 comments
Closed

[BUG] Solution explorer says "A compatible .Net SDK was not found" #194

y-chen opened this issue Jun 22, 2023 · 9 comments
Assignees
Labels
area-project-cps bug Something isn't working triaged The issue has been triaged

Comments

@y-chen
Copy link

y-chen commented Jun 22, 2023

Describe the Issue

Hi all,

I have a .Net 6 project that I want to open with vscode. So I installed the recommended C# Dev Kit extension but when I try to open a project in the Solution Explorer section I see "A compatible .Net SDK was not found" error instead of the content of the project and in the output tab I get the following logs:

2023-06-22 08:50:29.247 [info] Unhandled exception. System.BadImageFormatException: Could not load file or assembly '/Users/y.chen/.vscode-insiders/extensions/ms-dotnettools.csdevkit-0.2.70-darwin-arm64/components/CPS/platforms/darwin-arm64/node_modules/@microsoft/visualstudio-projectsystem-buildhost.darwin-arm64/Microsoft.VisualStudio.ProjectSystem.Server.BuildHost.dll'. An attempt was made to load a program with an incorrect format.

File name: '/Users/y.chen/.vscode-insiders/extensions/ms-dotnettools.csdevkit-0.2.70-darwin-arm64/components/CPS/platforms/darwin-arm64/node_modules/@microsoft/visualstudio-projectsystem-buildhost.darwin-arm64/Microsoft.VisualStudio.ProjectSystem.Server.BuildHost.dll'

2023-06-22 08:50:58.643 [info] Project system initialization finished. 0 project(s) are loaded, and 19 failed to load.

IntelliCode doesn't work either.

As suggested in another issue, I tried to install .Net on my laptop by downloading and installing it from this page (both x64 and arm64) but when I run dotnet --list-sdks, version 7 doesn't show up.

Steps To Reproduce

  1. Open .Net solution
  2. Open Solution Explorer

Expected Behavior

Solution Explorer shows project files and IntelliCode to work.

Environment Information

  • OS: macOS Ventura 13.3.1
  • VSCode: 1.80.0-insider (Universal)
  • Extension version: v0.2.70
@y-chen y-chen added the bug Something isn't working label Jun 22, 2023
@Michael-Eng Michael-Eng added the triaged The issue has been triaged label Jun 22, 2023
@lifengl
Copy link
Member

lifengl commented Jun 22, 2023

Hey y-chen, it is likely to be a platform specific issue. Different from other part of the extension, the BuildHost part was built on NET 6 runtime to work potentially with old SDKs, and then built to platform specific ready to run binaries.

Just to conform this is on new apple silicone -- basically a M1 or M2 machine, right?

@lifengl
Copy link
Member

lifengl commented Jun 22, 2023

Based on the information you mentioned earlier. It looks like that you installed both x64 and arm64 SDKs to your machine. I think you should only install the one matching your machine's hardware, either it is apple silicone machine, or intel based one. Both SDKs might be in the PATH. Since you installed Arm64 version of the extension, it would not work with x64 version of the SDK. You may need remove the incompatible version of the SDK from your machine to get it to work.

@rodrigovaras
Copy link

I have recent purchased a MacBook Pro M2 Pro. Installed vscode & C# extensions (version 2.7.0) and got the exact same problem. I just installed the default dotnet 7 SDK available for a Mac. When i open a solution i got the exact same problem described here, i don't see how the described workaround can fix this

@rodrigovaras
Copy link

I have recent purchased a MacBook Pro M2 Pro. Installed vscode & C# extensions (version 2.7.0) and got the exact same problem. I just installed the default dotnet 7 SDK available for a Mac. When i open a solution i got the exact same problem described here, i don't see how the described workaround can fix this

I now figure out the issue. I did uninstall the x64 SDK and install the arm64 SDK and now the extension works

@lifengl
Copy link
Member

lifengl commented Jun 28, 2023

@rodrigovaras : thanks a lot to conform the problem. Based on that, and how easy developer may install the SDK targeting wrong CPU, we will add logic to detect this condition, and provide more meaningful message for this situation.

BTW, @y-chen : if you run dotnet --info (which we ran when it fails to resolve SDK and prints out the output in the projects output window, you can verify whether SDK is x64 based in the RID field.

I haven't heard more information from @y-chen, and I will assume we have found the source of this problem. Once our new logic to provide better message is in, I will close this ticket.

@y-chen
Copy link
Author

y-chen commented Jun 30, 2023

Hi @lifengl ,

sorry for the late reply.

So I remove all the dotnet sdk and runtimes and just installed both latest .Net 6 and 7 (arm64). When I run dotnet --info I get this output:

.NET SDK:
 Version:   7.0.305
 Commit:    98e1b6c381

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  13.3
 OS Platform: Darwin
 RID:         osx.13-arm64
 Base Path:   /usr/local/share/dotnet/sdk/7.0.305/

Host:
  Version:      7.0.8
  Architecture: arm64
  Commit:       4b0550942d

.NET SDKs installed:
  6.0.411 [/usr/local/share/dotnet/sdk]
  7.0.305 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.19 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.19 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  x64   [/usr/local/share/dotnet/x64]
    registered at [/etc/dotnet/install_location_x64]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Now when I try to use the solution explorer I don't get the error as before but I still can't open a project. It keeps loading:

image

This is the extension output:

Starting Spawn .NET server...
Starting Open a solution...
Starting Open a solution with environment service...
Starting Clear environment...
.NET server started and IPC established in 838ms
Completed Spawn .NET server (842ms)
Completed Clear environment (1060ms)
Completed Open a solution with environment service (1102ms)
Starting Restore solution...
Completed Open a solution (1120ms)
Completed Restore solution (6628ms)

@lifengl
Copy link
Member

lifengl commented Jul 1, 2023

@y-chen : thanks to provide further information on this. I assume you saw the spinner when you expand a project.

we need check the extension log to see whether it can help us to narrow down the reason behind it:

1, open vscode extension log, and under ms-dotnettools.csdevkit/ServiceHub folder, most information would be inside

-Microsoft.VisualStudio.ProjectSystem.CompositionService--*****-1.log file, and you may see

-Microsoft.VisualStudio.ProjectSystem.ProjectTreeProvider-.log as well, and maybe we can find some errors reported there?

@lifengl
Copy link
Member

lifengl commented Jul 1, 2023

BTW, you may find a 'Projects' tab in the output window, which may print out some warning/errors from projects, which is separated from the extension output pane.

@lifengl
Copy link
Member

lifengl commented Jul 29, 2023

I closed this issue as the reason of the original problem was found. We now detect this condition and provide additional message to the user when we ran into this platform mismatching issue. We don't have enough information to understand the new issue @y-chen ran into later, and we haven't heard more on this thread. @y-chen : if you tried later previews and still run into problems to expand projects, you can open a new issue to track the problem, and attach some logs would be necessary for us to understand issues unique to your environment, and we don't hear or get information from other people.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-project-cps bug Something isn't working triaged The issue has been triaged
Projects
None yet
Development

No branches or pull requests

4 participants