基本上,我必须使用.net核心中的Addhocworkspace生成它。 我已经尝试了很多,但是看不到任何项目解决方案或物理文档文件。
代码:
var adHoc = new AdhocWorkspace();
var solutionInfo = SolutionInfo.Create(SolutionId.CreateNewId(), VersionStamp.Create(), "/ProjectSolution.sln");
adHoc.AddSolution(solutionInfo);
var projectInfo = ProjectInfo.Create(ProjectId.CreateNewId(), VersionStamp.Create(), "project", "project.csproj", "C#");
adHoc.AddProject(projectInfo);
SourceText sourceText = SourceText.From("class Program { static void Main() { System.Console.WriteLine(\"HelloWorld\"); } }");
//var documentInfo = DocumentInfo.Create(DocumentId.CreateNewId(projectInfo.Id), "project.cs");
adHoc.AddDocument(projectInfo.Id, "Program.cs", sourceText);
// adHoc.TryApplyChanges(adHoc.CurrentSolution);
var generator = SyntaxGenerator.GetGenerator(adHoc, "C#");