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?
您可以使用CommandLineProject.CreateProjectInfo
从set命令行参数创建项目,因此如果您有csc命令行,则可以使用它。
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!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.