[英]Roslyn: How to load an existing project outside of Visual Studio
As written in this question: 正如这个问题所写:
Can I access the MsBuildWorkspace from within a MsBuild Task class? 我可以从MsBuild Task类中访问MsBuildWorkspace吗?
You cannot use MSBuildWorkspace
from an MSBuild task for the same project. 您不能将
MSBuildWorkspace
用于同一项目。 However, the only 2 other options are VisualStudioWorkspace
and AdhocWorkspace
. 但是,只有其他两个选项是
VisualStudioWorkspace
和AdhocWorkspace
。
Does this mean that there's no option for loading a project from an MSBuild task? 这是否意味着没有从MSBuild任务加载项目的选项?
您可以使用CommandLineProject.CreateProjectInfo
从set命令行参数创建项目,因此如果您有csc命令行,则可以使用它。
I just found the solution in this post: Roslyn: workspace loads in console application but not in msbuild task 我刚刚在这篇文章中找到了解决方案: Roslyn:工作空间在控制台应用程序中加载,但在msbuild任务中没有
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!
实际上有一个好处,因为项目不再需要编译才能加载项目!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.