[quoted text, click to view] On Thu, 25 Mar 2004 10:36:32 -0700, Jonathan Turkanis wrote:
>Thanks, Henk. I never noticed this option either.
>
>I'm trying to build a bunch of regression tests for one projects.
>There are several dozen .cpp files which define main, and I want to
>build and run them separately. 'Exclude from build' would seem a
>natural choice here, but it's too hard to remember which file is
>currently included.
Hi Jonathan
I'm fairly new to VS but I've been interested to learn more about
writing macros and addins so I had a go at writing a macro to display
the included and excluded files for a project in the output window.
You'll probably have to change it to what you need. I mostly copied the
examples in the VS macro help - one VS example didn't work - I had to
use the col2 variable instead of file.FileConfigurations directly (as a
VS example does).
I'm unsure about creating a new output window pane - you might end up
with a bunch of new output window panes you don't want, so hopefully you
can change this if it doesn't look right. It appears to work for me.
You need to add Microsoft.VisualStudio.VCProjectEngine to the
"references" in the macro IDE - as the comment at the start shows. I
think this comment came from a VS example that I found by clicking on
help in the file configuration properties window, then clicking on
"ExcludedFromBuild". I think the macro below iterates through all open
projects but I only tried it with one open project. You might need to
clear the output window (there's a method for this) at some stage, but
it seemed to clear every time I ran the macro so I didn't add it. Also
I didn't try to figure out how to leave out header files and resource
files etc.
Graeme
' add reference to Microsoft.VisualStudio.VCProjectEngine
Imports EnvDTE
Imports Microsoft.VisualStudio.VCProjectEngine
Public Module Module1
Sub Test()
' Create a tool window handle for the Output window.
Dim win As Window =
DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
' Create handles to the Output window and its panes.
Dim OW As OutputWindow = win.Object
Dim OWp As OutputWindowPane
' Add a new pane to the Output window.
OWp = OW.OutputWindowPanes.Add("Project build exclude file
list")
Dim idx, idx2, idp As Integer
Dim file As VCFile
Dim col As IVCCollection
Dim col2 As IVCCollection
Dim fileconfig As VCFileConfiguration
Dim allproj As Projects
Dim prj As VCProject
allproj = DTE.Solution.Projects
For idp = 1 To allproj.Count
prj = allproj.Item(idp).Object
col = prj.Files
OWp.OutputString("PROJECT " + prj.Name + Chr(10))
For idx = 1 To col.Count
file = col.Item(idx)
col2 = file.FileConfigurations
OWp.OutputString(" " + file.Name + Chr(10))
For idx2 = 1 To col2.Count
fileconfig = col2.Item(idx2)
If fileconfig.ExcludedFromBuild Then
OWp.OutputString(" Excluded ")
Else
OWp.OutputString(" Included ")
End If
OWp.OutputString(col2.Item(idx2).Name() + Chr(10))
Next
Next
Next
OW.Parent.Activate()
OWp.Activate()
End Sub
End Module