muhammadsammy / free-vscode-csharp

Free/Libre fork of the official C# extension for vscode

Home Page:https://open-vsx.org/extension/muhammad-sammy/csharp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

System.InvalidOperationException: We don't have an MSBuild to use

Dreamoochy opened this issue · comments

I've updated to .NET 8, VSCodium 1.84.2 and free-vscode-csharp v2.10.28.
Now at the start I get the following notification for each project in a workspace:

[Error - 9:41:41 AM] [LanguageServerProjectSystem] Exception thrown while loading %file_path_of_csproj% StreamJsonRpc.RemoteInvocationException: We don't have an MSBuild to use; HasUsableMSBuildAsync should have been called first to check. - line 133
   at StreamJsonRpc.JsonRpc.InvokeCoreAsync[TResult](RequestId id, String targetName, IReadOnlyList`1 arguments, IReadOnlyList`1 positionalArgumentDeclaredTypes, IReadOnlyDictionary`2 namedArgumentDeclaredTypes, CancellationToken cancellationToken, Boolean isParameterObject)
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LanguageServerProjectSystem.LoadOrReloadProjectAsync(ProjectToLoad projectToLoad, BuildHostProcessManager buildHostProcessManager, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs:line 206
RPC server exception:
System.InvalidOperationException: We don't have an MSBuild to use; HasUsableMSBuildAsync should have been called first to check. - line 133
      at Roslyn.Utilities.Contract.Fail(String message, Int32 lineNumber) in /_/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/Contract.cs:line 154
      at Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.BuildHost.EnsureMSBuildLoaded(String projectFilePath) in /_/src/Workspaces/Core/MSBuild.BuildHost/BuildHost.cs:line 133
      at Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.BuildHost.IsProjectFileSupportedAsync(String projectFilePath, CancellationToken cancellationToken) in /_/src/Workspaces/Core/MSBuild.BuildHost/BuildHost.cs:line 163
      at InvokeStub_BuildHost.IsProjectFileSupportedAsync(Object, Object, IntPtr*)
      at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)

I've updated to .NET 8, VSCodium 1.84.2 and free-vscode-csharp v2.10.28. Now at the start I get the following notification for each project in a workspace:

[Error - 9:41:41 AM] [LanguageServerProjectSystem] Exception thrown while loading %file_path_of_csproj% StreamJsonRpc.RemoteInvocationException: We don't have an MSBuild to use; HasUsableMSBuildAsync should have been called first to check. - line 133
   at StreamJsonRpc.JsonRpc.InvokeCoreAsync[TResult](RequestId id, String targetName, IReadOnlyList`1 arguments, IReadOnlyList`1 positionalArgumentDeclaredTypes, IReadOnlyDictionary`2 namedArgumentDeclaredTypes, CancellationToken cancellationToken, Boolean isParameterObject)
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LanguageServerProjectSystem.LoadOrReloadProjectAsync(ProjectToLoad projectToLoad, BuildHostProcessManager buildHostProcessManager, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs:line 206
RPC server exception:
System.InvalidOperationException: We don't have an MSBuild to use; HasUsableMSBuildAsync should have been called first to check. - line 133
      at Roslyn.Utilities.Contract.Fail(String message, Int32 lineNumber) in /_/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/Contract.cs:line 154
      at Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.BuildHost.EnsureMSBuildLoaded(String projectFilePath) in /_/src/Workspaces/Core/MSBuild.BuildHost/BuildHost.cs:line 133
      at Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.BuildHost.IsProjectFileSupportedAsync(String projectFilePath, CancellationToken cancellationToken) in /_/src/Workspaces/Core/MSBuild.BuildHost/BuildHost.cs:line 163
      at InvokeStub_BuildHost.IsProjectFileSupportedAsync(Object, Object, IntPtr*)
      at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)

Same for me, is .NET 8 support coming?

in the meantime any workaround is appreciated.

Can't reproduce. What OS are you using? Try updating the extension to v2.12.19

Apparently fixed!

The problem was consistent in all Unity3D projects after updating .Net Code to 8.0.
OS: Arch Linux
free-vscode-csharp: v2.10.28
VSCodium: v1.84.2

After updating to v2.12.19 the behavior does not occur anymore in any project.
Thank You!