1

Microsoft.CodeAnalysis Version Used: 2.3.2

Steps to Reproduce:

Create a VSIX (c#) project in Visual Studio 2015 Update 3 with .Net framework 4.6 Add latest Microsoft.CodeAnalysis library to VSIX project Add menu command to the VSIX project Add following code in menu command action

string projectFilePath = @"C:\ConsoleApp1\ConsoleApp1.csproj";
string outputFilePath = @"C:\ConsoleApp1\ConsoleApp1.dll";
Project project = null;

    using (var workspace = MSBuildWorkspace.Create())
    {
        project = workspace.OpenProjectAsync(projectFilePath).Result;
        var compilation = project.GetCompilationAsync().Result;
        var compilationStatus = compilation.Emit(outputFilePath);
        bool isSuccess = compilationStatus.Success; 
    }

Expected Behavior: Roslyn should be able to compile the project and emit output to target location.

Actual Behavior: Following exception occurred when invoking the command.

Could not load file or assembly 'Microsoft.CodeAnalysis.Workspaces, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Note: Error doesn't occur and command executes successfully when version of the Microsoft.CodeAnalysis is downgraded to 1.3.2

Please let me know if any fix is available for this issue.

Bandara
  • 780
  • 8
  • 29

1 Answers1

3

see What's the latest version of Roslyn my analyzer can target if I support VS2015?. Roslyn 1.3.2 is the newest version that will work with Visual Studio 2015 Update 3

Jonathon Marolf
  • 2,071
  • 14
  • 16
  • Thanks Jonathan Marlof, As per your post, Roslyn is not backward compatible, which means my extension will not work in VS 2015 Update 3 if I upgrade to latest. Do you know any solution to make it compatible with both VS 2015 Update 3 and VS 2017 Update 3 ? – Bandara Oct 10 '17 at 05:39
  • If you reference version 1.3.2 your extension will work on both. – Jonathon Marolf Oct 11 '17 at 15:24
  • Thanks @Jonathon, I have downgraded to 1.0.0, now it works in 2015 Update 3 and 2017 Update 3, hoping it will work in all the versions greater than Visual Studio 2015.0 (RTM) – Bandara Oct 12 '17 at 13:49