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
19.07k stars 4.04k forks source link

WorkspaceDiagnostic Issue Error #43683

Open abhijitparkhi1983 opened 4 years ago

abhijitparkhi1983 commented 4 years ago

Version Used: 3.5.0

Steps to Reproduce:

  1. Use MSBuildLocator.QueryVisualStudioInstances() for getting the MsBuild Instance
  2. Using below code open .csproj :

    using (var workspace = MSBuildWorkspace.Create()) 
    { 
         Project currentProject = workspace.OpenProjectAsync(projectPath).Result; 
         workspace.LoadMetadataForReferencedProjects = true; 
    
         ImmutableList<WorkspaceDiagnostic> diagnostics = workspace.Diagnostics;
    foreach (var diagnostic in diagnostics)
    {
      Logger.Log("Project Issue Diagnostic Issues: " + currentProject.Name + "::::" + diagnostic.Message, this, null, LogType.Info);
    }
    }

    Expected Behavior: Should not have any WorkspaceDiagnostic issues.

Actual Behavior: Project Issue Diagnostic Issues: Roslyn.VisualStudio.InteractiveComponents::::Msbuild failed when processing the file with message: C:\Users.nuget\packages\microsoft.net.compilers.toolset\3.7.0-1.20210.7\tasks\netcoreapp3.1\Microsoft.CSharp.Core.targets: (59, 5): The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly C:\Users.nuget\packages\microsoft.net.compilers.toolset\3.7.0-1.20210.7\build..\tasks\netcoreapp3.1\Microsoft.Build.Tasks.CodeAnalysis.dll. Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

NOTE : I have added a refrence to System.Runtime already.

abhijitparkhi1983 commented 4 years ago

Any inputs on this team Roslyn