Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuildWorkspace.Create() - Supported languages is zero

Tags:

c#

roslyn

I am using the roslyn Formatter.Format() method to format some c#.

One of the parameters takes a Workspace object which can be created using MSBuildWorkspace.Create().

However, when I run the code I get a runtime exception because the workspace comes back with no supported languages. If I run this in console application it works fine.

Any ideas?

like image 377
user2697817 Avatar asked Jul 07 '14 15:07

user2697817


1 Answers

Make sure to deploy Microsoft.CodeAnalysis.CSharp.Workspaces.dll and/or Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll with your app.

The workspace dynamically discovers which languages it has support for by loading those assemblies.

like image 158
Kevin Pilch Avatar answered Oct 23 '22 13:10

Kevin Pilch