Reputation: 800
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.
Upvotes: 1
Views: 1168
Reputation: 2089
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
Upvotes: 3