Vb.net MSBuildWorkspace.Create在VB中似乎无法正常工作

Vb.net MSBuildWorkspace.Create在VB中似乎无法正常工作,vb.net,msbuild,roslyn,Vb.net,Msbuild,Roslyn,在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

在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