0
RoslynでVisual Studioソリューションを開いて、プロジェクトとドキュメントを繰り返し処理しようとしています。私は何にも書きたくない。下のコードでNewSolution.Projects.countは常に0です。最終的には、各文書のSemanticModelを取得したいと考えています。RoslynでVisual Studioソリューションを開きます
Const SolutionPartialPath As String = "Visual Studio 2017\Projects\roslyn-master\src\Samples\Samples.sln"
<TestMethod()> Public Sub UnitTest1()
Dim myDoc As String = My.Computer.FileSystem.SpecialDirectories.MyDocuments
Dim SampleSolutionPath As String = Path.Combine(myDoc, SolutionPartialPath)
Dim WS As AdhocWorkspace = New AdhocWorkspace()
Dim SolInfo As SolutionInfo = SolutionInfo.Create(SolutionId.CreateNewId, VersionStamp.Create, SampleSolutionPath)
Dim NewSolution As Solution = WS.AddSolution(SolInfo)
For Each project As Project In NewSolution.Projects
Debug.WriteLine(project.Name)
If project.Name = "BasicAnalyzers" Then
For Each document In project.Documents
Debug.WriteLine(document.Name)
ProcessOneFile(document)
Next document
End If
Next project
End Sub
おかげで、私は解決策を開き、プロジェクトを反復処理することができていますが、彼らはthem.Iに文書が(project.FilePath).Result WS.OpenProjectAsyncを見ていないが、それは単にワークスペースにすでにドキュメントに関するエラーを取得しています。 –
プログラムが正しいようですが、問題は "SDK 'Microsoft.NET.Sdk'が見つかりませんでした。 AddHandler MS_Workspace.WorkspaceFailed、Sub(送信者オブジェクト、e As WorkspaceDiagnosticEventArgs)を追加しない限り表示されません。今私はその問題を修正する必要があります。 –