I am using .Net 4.8 Console project with such NuGet packages
Microsoft.CodeAnalysis.CSharp.3.8.0
Microsoft.CodeAnalysis.CSharp.Workspaces.3.8.0
Microsoft.CodeAnalysis.Workspaces.MSBuild.3.8.0
Program.cs
MSBuildWorkspace workspace = MSBuildWorkspace.Create();
Solution currSolution = workspace.OpenSolutionAsync(@"C:\Users\***\source\repos\WpfApp5\WpfApp5.sln").Result;
OpenSolutionAsync throwing exception
Object reference not set to an instance of an object.
Stack trace
at Microsoft.Build.Shared.BuildEnvironmentHelper.get_Instance()
at Microsoft.Build.Utilities.Traits.get_Instance()
at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties, IEnumerable`1 loggers, IEnumerable`1 remoteLoggers, ToolsetDefinitionLocations toolsetDefinitionLocations, Int32 maxNodeCount, Boolean onlyLogCriticalEvents, Boolean loadProjectsReadOnly)
at Microsoft.CodeAnalysis.MSBuild.Build.ProjectBuildManager.StartBatchBuild(IDictionary`2 globalProperties)
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.<LoadAsync>d__19.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.<LoadSolutionInfoAsync>d__21.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.<OpenSolutionAsync>d__24.MoveNext()
I found only this issue and its looks like this error already not fixed for 5 years? Is there any solution or workaround that allows to open solution?