'C# programm can't find my workspace with MSBuildWorkspace

Hi I am trying to analyze my CsProj using Roslyn. I'm having issues finding my solution. This is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.MSBuild;
namespace Test
{
    class Programm
    {
        static async Task Main(string[] args)
        {
            SourceAnalyzer sa = new SourceAnalyzer();

            string path = @"C:\Users\lhafer\source\repos\Farm\Farm\Farm.csproj";

            using (var workspace = MSBuildWorkspace.Create())
            {
                var project = await workspace.OpenProjectAsync(path);
                var compilation = await project.GetCompilationAsync();
            }

            //sa.Analyze(path).Wait();
        }
    }
}   

the Exception says:

System.Reflection.ReflectionTypeLoadException: "Unable to load one or more of the requested types.
Could not load file or assembly 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Thank you for your help!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source