Wednesday, August 11, 2010

More Time Saving Macros Who's Under Source Control

I am in the process of switching from Subversion to Teams Server source control. Unfortunately when merging project files the source control in teams is not applied causing build errors. Using my last macro as an example I now scan every file in the solution to see if it is in source control and correct if not. One could probably add the extra code to add the item to source control.

Public Module SourceControlScanner
Private Sub Write(ByVal name As String, ByVal message As String)
Dim output As Window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
Dim window As OutputWindow = output.Object
Dim pane As OutputWindowPane = window.OutputWindowPanes.Item(name)
End Sub
Private Sub Scan(ByVal project As Project)
If Not project.ProjectItems Is Nothing Then
If TypeOf (project.Object) Is VSProject Then
Dim visualStudioProject As VSProject = DirectCast(project.Object, VSProject)
For Each item As ProjectItem In project.ProjectItems
For index As Integer = 0 To item.FileCount
Dim file As String = item.FileNames(index)
If Not visualStudioProject.DTE.SourceControl.IsItemUnderSCC(file) Then
Write("Debug", String.Concat(project.Name, " ", item.Name))
End If
End If
For Each childProjectItem As ProjectItem In project.ProjectItems
If Not childProjectItem.SubProject Is Nothing Then Scan(childProjectItem.SubProject)
End If
End Sub
Public Sub CheckSourceControl()
For Each project As Project In DTE.Solution.Projects
End Sub
End Module

No comments:

Post a Comment