2011-08-05 35 views
0

我正在尋找一種方法來輸出Visual Studio項目中所有文件的列表,以便進行文檔編制。輸出屬於Visual Studio項目的文件列表

我原以爲這是可能的,但我找不到任何信息。我不是在談論使用Sandcastle來連接XML註釋,我只是想要一個「簡單」縮進的項目文件列表。

我猜我們可以對Proj文件運行一個xsl文件,但希望有人已經有這個解決方案?理想情況下,這將在2008年和2010年都有效。

回答

1

VS2008示例宏已經包含一個實際執行此操作的宏(將源/頭文件列表輸出到輸出窗口)。它被稱爲ListProj1,在Utilities樣本下。下面是代碼,如果你沒有它:

Sub ListProj() 
    Dim project As Project 
    Dim projectObjects As Object() 
    Dim window As Window 
    Dim target As Object 
    window = DTE.Windows.Item(Constants.vsWindowKindCommandWindow) 
    projectObjects = DTE.ActiveSolutionProjects 
    If projectObjects.Length = 0 Then 
    Exit Sub 
    End If 
    project = DTE.ActiveSolutionProjects(0) 
    If (DTE.ActiveWindow Is window) Then 
    target = window.Object 
    Else 
    target = GetOutputWindowPane("List Project") 
    target.Clear() 
    End If 
    ListProjAux(project.ProjectItems(), 0, target) 
End Sub 

Sub ListProjAux(ByVal projectItems As EnvDTE.ProjectItems, ByVal level As Integer, ByVal outputWinPane As Object) 
    Dim projectItem As EnvDTE.ProjectItem 
    For Each projectItem In projectItems 
     If projectItem.Collection Is projectItems Then 
      Dim projectItems2 As EnvDTE.ProjectItems 
      Dim notSubCollection As Boolean 
      OutputItem(projectItem, level, outputWinPane) 
      '' Recurse if this item has subitems ... 
      projectItems2 = projectItem.ProjectItems 
      notSubCollection = projectItems2 Is Nothing 
      If Not notSubCollection Then 
       ListProjAux(projectItems2, level + 1, outputWinPane) 
      End If 
     End If 
    Next 
End Sub 

Sub OutputItem(ByVal projectItem As EnvDTE.ProjectItem, ByVal level As Integer, ByVal outputWinPane As Object) 
    Dim i As Integer = 0 
    While (i < level) 
     outputWinPane.OutputString(" ") 
     i = i + 1 
    End While 
    outputWinPane.OutputString(projectItem.FileNames(1)) 
    outputWinPane.OutputString(Microsoft.VisualBasic.Constants.vbCrLf) 
End Sub 
相關問題