Roslyn throws The language 'C#' is not supported

坚强是说给别人听的谎言 提交于 2019-12-04 22:47:49
Johannes Egger

Most likely it's because you don't reference Microsoft.CodeAnalysis.CSharp.Workspaces in your code, i.e. you never use a type or method in this dll, so MSBuild thinks it's not needed (see e.g. this question).

So what you could do is e.g. add the following line somewhere in your class library project:

var _ = typeof(Microsoft.CodeAnalysis.CSharp.Formatting.CSharpFormattingOptions);

Then MSBuild should copy Microsoft.CodeAnalysis.CSharp.Workspaces.dll over and everything should be fine. No need to reference the NuGet packages from all the other projects.

You have to add the Microsoft.CodeAnalysis package to both the class library project AND the referencing project as well.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!