Roslyn: How to load an existing project outside of Visual Studio

北城余情 提交于 2019-12-23 15:25:56

问题


As written in this question:

Can I access the MsBuildWorkspace from within a MsBuild Task class?

You cannot use MSBuildWorkspace from an MSBuild task for the same project. However, the only 2 other options are VisualStudioWorkspace and AdhocWorkspace.

Does this mean that there's no option for loading a project from an MSBuild task?


回答1:


You can create a Project from a set command line arguments using CommandLineProject.CreateProjectInfo, so if you have the csc command line, you can use that.




回答2:


I just found the solution in this post: Roslyn: workspace loads in console application but not in msbuild task

It still feels as a workaround, however it's working. There's actually a benefit to it in that the project doesn't have to be compiled anymore in order to load the project!



来源:https://stackoverflow.com/questions/31084013/roslyn-how-to-load-an-existing-project-outside-of-visual-studio

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