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

Project load failure - Failed to find all versions of .NET Core MSBuild. Call to hostfxr_resolve_sdk2 #6335

Closed
winzig opened this issue Sep 11, 2023 · 15 comments

Comments

@winzig
Copy link

winzig commented Sep 11, 2023

Type: Bug

Issue Description

(Running on macOS Silicon)

Just recently have suddenly been having problems with definition not found when trying to do code navigation, e.g. right-click on a class name and "Go to Definition." Never had this problem before, but no matter how many restarts, reinstalls of the C# extension, etc., can't seem to get it working again.

Steps to Reproduce

I open up my usual C# project, build it (no errors), and then try to do things like "Go to Definition" on a class name or the like, and I get the "No definition found for..." error.

Logs

logs.zip

Environment information

VSCode version: 1.82.0
C# Extension: 2.1.2
Using OmniSharp: false

Dotnet Information Error running dotnet --info: Error: Command failed: /Users/tom/Library/Application Support/Code/User/globalStorage/ms-dotnettools.vscode-dotnet-runtime/.dotnet/7.0.10/dotnet --info /bin/sh: /Users/tom/Library/Application: No such file or directory

/bin/sh: /Users/tom/Library/Application: No such file or directory

Visual Studio Code Extensions
Extension Author Version Folder Name
auto-dark-mode LinusU 0.1.7 linusu.auto-dark-mode-0.1.7
aws-toolkit-vscode amazonwebservices 1.89.0 amazonwebservices.aws-toolkit-vscode-1.89.0
Bookmarks alefragnani 13.4.1 alefragnani.bookmarks-13.4.1
code-navigation vikas 0.2.0 vikas.code-navigation-0.2.0
codestream CodeStream 14.28.0 codestream.codestream-14.28.0
copilot GitHub 1.110.389 github.copilot-1.110.389
copilot-chat GitHub 0.7.0 github.copilot-chat-0.7.0
copilot-labs GitHub 0.15.1019 github.copilot-labs-0.15.1019
csharp ms-dotnettools 2.1.2 ms-dotnettools.csharp-2.1.2-darwin-arm64
data-workspace-vscode ms-mssql 0.5.0 ms-mssql.data-workspace-vscode-0.5.0
dotnet-interactive-vscode ms-dotnettools 1.0.4403010 ms-dotnettools.dotnet-interactive-vscode-1.0.4403010
EditorConfig EditorConfig 0.16.4 editorconfig.editorconfig-0.16.4
flux influxdata 1.0.4 influxdata.flux-1.0.4
gc-excelviewer GrapeCity 4.2.58 grapecity.gc-excelviewer-4.2.58
github-vscode-theme GitHub 6.3.4 github.github-vscode-theme-6.3.4
gitlens eamodio 14.3.0 eamodio.gitlens-14.3.0
go golang 0.39.1 golang.go-0.39.1
hexeditor ms-vscode 1.9.12 ms-vscode.hexeditor-1.9.12
intellicode-api-usage-examples VisualStudioExptTeam 0.2.8 visualstudioexptteam.intellicode-api-usage-examples-0.2.8
isort ms-python 2023.10.1 ms-python.isort-2023.10.1
java redhat 1.21.0 redhat.java-1.21.0-darwin-arm64
js-debug-nightly ms-vscode 2023.8.3017 ms-vscode.js-debug-nightly-2023.8.3017
jupyter ms-toolsai 2023.8.1002501831 ms-toolsai.jupyter-2023.8.1002501831-darwin-arm64
jupyter-keymap ms-toolsai 1.1.2 ms-toolsai.jupyter-keymap-1.1.2
jupyter-renderers ms-toolsai 1.0.17 ms-toolsai.jupyter-renderers-1.0.17
markdown-preview-enhanced shd101wyy 0.7.3 shd101wyy.markdown-preview-enhanced-0.7.3
mssql ms-mssql 1.20.1 ms-mssql.mssql-1.20.1
partial-diff ryu1kn 1.4.3 ryu1kn.partial-diff-1.4.3
php-debug xdebug 1.33.0 xdebug.php-debug-1.33.0
php-intellisense zobo 1.3.2 zobo.php-intellisense-1.3.2
php-pack xdebug 1.0.3 xdebug.php-pack-1.0.3
powershell ms-vscode 2023.6.0 ms-vscode.powershell-2023.6.0
prettify-json mohsen1 0.0.3 mohsen1.prettify-json-0.0.3
python ms-python 2023.16.0 ms-python.python-2023.16.0
quicktype-refresh doggy8088 1.0.2 doggy8088.quicktype-refresh-1.0.2
regexp-preview LouisWT 0.1.5 louiswt.regexp-preview-0.1.5
sourcekit-lsp unpublished 0.0.1 unpublished.sourcekit-lsp-0.0.1
sql-bindings-vscode ms-mssql 0.4.0 ms-mssql.sql-bindings-vscode-0.4.0
sql-database-projects-vscode ms-mssql 1.2.0 ms-mssql.sql-database-projects-vscode-1.2.0
swift Kasik96 0.2.0 kasik96.swift-0.2.0
swiftlint shinnn 0.1.3 shinnn.swiftlint-0.1.3
test-adapter-converter ms-vscode 0.1.8 ms-vscode.test-adapter-converter-0.1.8
todo-tree Gruntfuggly 0.0.226 gruntfuggly.todo-tree-0.0.226
unique-lines bibhasdn 1.0.0 bibhasdn.unique-lines-1.0.0
vetur octref 0.37.3 octref.vetur-0.37.3
vs-color-picker lihui 1.0.0 lihui.vs-color-picker-1.0.0
vscode-cfn-lint kddejong 0.24.5 kddejong.vscode-cfn-lint-0.24.5
vscode-commons redhat 0.0.6 redhat.vscode-commons-0.0.6
vscode-docker ms-azuretools 1.26.0 ms-azuretools.vscode-docker-1.26.0
vscode-dotnet-runtime ms-dotnettools 1.7.2 ms-dotnettools.vscode-dotnet-runtime-1.7.2
vscode-eslint dbaeumer 2.4.2 dbaeumer.vscode-eslint-2.4.2
vscode-github-actions github 0.26.2 github.vscode-github-actions-0.26.2
vscode-icons-mac wayou 7.25.3 wayou.vscode-icons-mac-7.25.3
vscode-java-debug vscjava 0.54.0 vscjava.vscode-java-debug-0.54.0
vscode-java-dependency vscjava 0.23.1 vscjava.vscode-java-dependency-0.23.1
vscode-java-pack vscjava 0.25.13 vscjava.vscode-java-pack-0.25.13
vscode-java-test vscjava 0.39.1 vscjava.vscode-java-test-0.39.1
vscode-jupyter-cell-tags ms-toolsai 0.1.8 ms-toolsai.vscode-jupyter-cell-tags-0.1.8
vscode-jupyter-slideshow ms-toolsai 0.1.5 ms-toolsai.vscode-jupyter-slideshow-0.1.5
vscode-m3u af4jm 1.0.0 af4jm.vscode-m3u-1.0.0
vscode-maven vscjava 0.42.0 vscjava.vscode-maven-0.42.0
vscode-nuget-package-manager jmrog 1.1.6 jmrog.vscode-nuget-package-manager-1.1.6
vscode-pull-request-github GitHub 0.72.0 github.vscode-pull-request-github-0.72.0
vscode-pylance ms-python 2023.9.10 ms-python.vscode-pylance-2023.9.10
vscode-test-explorer hbenl 2.21.1 hbenl.vscode-test-explorer-2.21.1
vscode-xml redhat 0.26.1 redhat.vscode-xml-0.26.1-darwin-arm64
vscode-yaml redhat 1.14.0 redhat.vscode-yaml-1.14.0
vscodeintellicode VisualStudioExptTeam 1.2.30 visualstudioexptteam.vscodeintellicode-1.2.30
webvalidator CelianRiboulet 1.3.1 celianriboulet.webvalidator-1.3.1
xml DotJoshJohnson 2.5.1 dotjoshjohnson.xml-2.5.1

Extension version: 2.1.2
VS Code version: Code 1.82.0 (8b617bd08fd9e3fc94d14adb8d358b56e3f72314, 2023-09-06T22:08:29.670Z)
OS version: Darwin arm64 22.6.0
Modes:

System Info
Item Value
CPUs Apple M1 Max (10 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) 3, 3, 3
Memory (System) 64.00GB (21.72GB free)
Process Argv --crash-reporter-id 7fa3914a-6723-4a59-8df2-d01755446466
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
vscaac:30438847
vsclangdf:30486550
c4g48928:30535728
dsvsc012:30540252
pynewext54:30695312
azure-dev_surveyone:30548225
vscccc:30803845
2e4cg342:30602488
89544117:30613380
showlangstatbar:30737416
a2ce3375:30757347
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxpt:30805730
pythonnoceb:30805159
synctok:30821570
dsvsc013:30795093
dsvsc014:30804076
diffeditorv1:30821571
dsvsc015:30829745

@winzig
Copy link
Author

winzig commented Sep 11, 2023

Also, I downgraded to 2.0.436 and the issues have gone away, so it's something new. I also tried the pre-release, but the issue was still there, so staying on 2.0.436 for now.

@dibarbet
Copy link
Member

@winzig would you mind sharing the output of dotnet --info here as well? Looks there was an error running it (to be fixed by #6334)

@dibarbet
Copy link
Member

From the logs:

[Error - 10:33:08 AM] [LanguageServerHost]System.InvalidOperationException: Failed to find all versions of .NET Core MSBuild. Call to hostfxr_resolve_sdk2. There may be more details in stderr.
   at Microsoft.Build.Locator.DotNetSdkLocationHelper.GetSdkFromGlobalSettings(String workingDirectory)
   at Microsoft.Build.Locator.DotNetSdkLocationHelper.GetDotNetBasePaths(String workingDirectory)+MoveNext()
   at Microsoft.Build.Locator.DotNetSdkLocationHelper.GetInstances(String workingDirectory)+MoveNext()
   at Microsoft.Build.Locator.MSBuildLocator.GetInstances(VisualStudioInstanceQueryOptions options)+MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LanguageServerProjectSystem.TryEnsureMSBuildLoadedAsync(String workingDirectory) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs:line 159
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LanguageServerProjectSystem.OpenSolutionAsync(String solutionFilePath) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs:line 97
   at Microsoft.CommonLanguageServerProtocol.Framework.QueueItem`3.StartRequestAsync(TRequestContext context, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/QueueItem.cs:line 136

@winzig
Copy link
Author

winzig commented Sep 11, 2023

@dibarbet Sure here you go:

.NET SDK (reflecting any global.json):
 Version:   6.0.101
 Commit:    ef49f6213a

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  13.5
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /usr/local/share/dotnet/sdk/6.0.101/

Host (useful for support):
  Version: 6.0.1
  Commit:  3a25a7f1cc

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

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

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

@dibarbet
Copy link
Member

dibarbet commented Sep 11, 2023

Thanks - the dotnet info looks fine.
@winzig can you confirm that it is broken in 2.0.448 as well? If it is I'm almost certain it is related to
dotnet/roslyn#69769

@winzig
Copy link
Author

winzig commented Sep 11, 2023

@dibarbet I'm not seeing 2.0.448 in the releases for vscode-csharp?

@dibarbet
Copy link
Member

Apologies - we had to redo the version numbers so 2.0.448 = 2.1.2. So most likely caused by dotnet/roslyn#69769. Will followup on their side to see what we might need to do.

@dibarbet
Copy link
Member

dibarbet commented Sep 12, 2023

Another report here - #6346

@dibarbet
Copy link
Member

Update -

We've been able to reproduce this and are looking into the best way of fixing this. As a temporary workaround I think if you install the .NET 7 SDK alongside the .NET 6 SDK it should allow the project to load successfully.

@dibarbet dibarbet changed the title No definition found for ... Project load - Failed to find all versions of .NET Core MSBuild. Call to hostfxr_resolve_sdk2 Sep 12, 2023
@dibarbet dibarbet changed the title Project load - Failed to find all versions of .NET Core MSBuild. Call to hostfxr_resolve_sdk2 Project load failure - Failed to find all versions of .NET Core MSBuild. Call to hostfxr_resolve_sdk2 Sep 12, 2023
@b26168
Copy link

b26168 commented Sep 14, 2023

I just rollback to v2.0.436 for workaround.

@dibarbet
Copy link
Member

Currently tracking microsoft/MSBuildLocator#243 as a potential fix. Will need to update the server to consume this new version once it merges.

@dibarbet
Copy link
Member

We just released version 2.3.27 of the C# extension which should resolve this issue.

If you're still having issues after upgrading, please open a new issue. Thanks!

@winzig
Copy link
Author

winzig commented Sep 22, 2023

Thank you, WFM

@michaelmarziani
Copy link

Syntax highlighting, cmd+click, and on-hover info is working again for me. Thanks!

@sliekens
Copy link

v2.3.27 works great for me in Debian Dev Containers, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants