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

时间:2018-08-09 22:41:10

标签: 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
    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

0 个答案:

没有答案