muhammadsammy / free-vscode-csharp

Free/Libre fork of the official C# extension for vscode
https://open-vsx.org/extension/muhammad-sammy/csharp
Other
110 stars 10 forks source link

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

Open Dreamoochy opened 7 months ago

Dreamoochy commented 7 months ago

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)
ixkipe commented 7 months ago

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?

Said1996 commented 7 months ago

in the meantime any workaround is appreciated.

muhammadsammy commented 7 months ago

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

herbertsschaefe commented 7 months ago

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!