Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Thanks to @JaredPar and @lpthnc for pointing me in the right direction. I ended up using an approach very similar to what @JaredPar outlines above. Here's my working macro FWIW.</p> <pre><code>Imports System.IO Imports System.Collections.Generic Imports EnvDTE Public Module Main Sub IncludeNewFiles() Dim Count As Integer = 0 For Each Project As Project In DTE.Solution.Projects If Project.UniqueName.EndsWith(".vbproj") Then Dim NewFiles As List(Of String) = GetFilesNotInProject(Project) For Each File In NewFiles Project.ProjectItems.AddFromFile(File) Next Count += NewFiles.Count End If Next DTE.StatusBar.Text = String.Format("{0} new file{1} included in the project.", Count, If(Count = 1, "", "s")) End Sub Private Function GetAllProjectFiles(ByVal ProjectItems As ProjectItems, ByVal Extension As String) As List(Of String) GetAllProjectFiles = New List(Of String) For Each ProjectItem As ProjectItem In ProjectItems For i As Integer = 1 To ProjectItem.FileCount Dim FileName As String = ProjectItem.FileNames(i) If Path.GetExtension(fileName).ToLower = Extension Then GetAllProjectFiles.Add(fileName) End If Next GetAllProjectFiles.AddRange(GetAllProjectFiles(ProjectItem.ProjectItems, Extension)) Next End Function Private Function GetFilesNotInProject(ByVal Project As Project) As List(Of String) Dim StartPath As String = Path.GetDirectoryName(Project.FullName) Dim ProjectFiles As List(Of String) = GetAllProjectFiles(Project.ProjectItems, ".vb") GetFilesNotInProject = New List(Of String) For Each file In Directory.GetFiles(StartPath, "*.vb", SearchOption.AllDirectories) If Not ProjectFiles.Contains(file) Then GetFilesNotInProject.Add(file) Next End Function End Module </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload