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? 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