2011-08-05 6 views
0

私はVisual Studioプロジェクトのすべてのファイルの一覧を出力する方法を探しています。Visual Studioプロジェクトの一部であるファイルの一覧を出力する

これは可能かもしれないと思っていましたが、情報が見つかりませんでした。私はサンドキャッスルを使ってXMLコメントにフックすることについて話しているわけではありません。プロジェクトファイルを「シンプル」にインデントしたいだけです。

私はProjファイルに対してxslファイルを実行できると推測していますが、うまくいけば、誰かがすでにこのための解決策を持っていますか?理想的には、これは2008年と2010の両方で動作します。

答えて

1

VS2008サンプルマクロには、実際にこれを行うマクロが含まれています(出力ウィンドウにソース/ヘッダーファイルのリストを出力します)。これはUtilitiesサンプルの下にListProj1と呼ばれています。あなたが持っていない場合のコードは次のとおりです:

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 
関連する問題