dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.69k stars 3.98k forks source link

Error in 【MSBuildWorkspace.Create() .OpenSolutionAsync()】:System.Exception (cannotfound BuildHost) #74070

Open Miltomo opened 1 week ago

Miltomo commented 1 week ago

Version Used: 17.11.0 Preview 2.1

Error Message: Unable to find build host in “c:\program files\microsoft visual studio\2022\preview\common7\ide\commonextensions\microsoft\vbcsharp\languageservices\BuildHost-netcore\Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.dll”

Steps to Reproduce:

  1. I am developing VS extensions 【VSIX Project】
  2. I'm just using Microsoft.CodeAnalysis.MSBuild to get a Solution var
  3. I have tried many methods (such as using Locator to register, but in reality, Locator will report an error saying that an instance already exists), but this error still occurs
  4. In fact, I checked the folder and found that the "BuildHost-netcore" folder does not exist under ..\Commonextensions\Microsoft\VBCSharp\LanguageServices
  5. Annoying BuildHost, annoying bad code, I think I have known why no one want to develop VS extensions

StackTrace: 在 Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.AssertBuildHostExists(String buildHostPath) 在 Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.GetNetCoreBuildHostPath() 在 Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.CreateDotNetCoreBuildHostStartInfo() 在 Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.d9.MoveNext() 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 在 Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.d8.MoveNext() 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 在 Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.d20.MoveNext() 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 在 Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.d21.MoveNext() 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.d19.MoveNext() 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 在 Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.d23.MoveNext() 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.d23.MoveNext() 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 在 Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.d25.MoveNext() 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 在 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()

Version Info: C:\Users\Administrator>dotnet --info .NET SDK: Version: 8.0.302 Commit: ef14e02af8 Workload version: 8.0.300-manifests.c3d67e2f MSBuild version: 17.10.4+10fbfbf2e

kamronbatman commented 1 week ago

Yeah I am getting the same error. This seems to be a combination of the bump to 4.9.0 or 4.10.0, and 8.0.302. On my CI/CD (Azure Pipelines, newest windows and .NET 8.0.302), it never finishes finding the solution and the program hangs indefinitely.