在VS 2017,.Net Framework 4.7.1中,我使用以下代码获取项目中的C#源文件列表,并且currentProject.HasDocuments始终返回False。没有错误返回。
Using Workspace As MSBuildWorkspace = MSBuildWorkspace.Create()
Dim currentProject As Project = Workspace.OpenProjectAsync(ProjectPath).Result
Workspace.LoadMetadataForReferencedProjects = True
If currentProject.HasDocuments Then
For Each document As Document In currentProject.Documents
Dim DocumentName As String = document.Name
ProcessFile(document.FilePath, currentProject.MetadataReferences.ToArray)
Next document
End If
End Using