I'm trying to go through all projects of our Visual Studio 2008 solution programmatically in order to ensure correct values of certain project settings.
I'm trying to do it with VBS and DTE but I don't insist on using a particular language/API/framework, except that I wouldn't like to make adjustments to project settings at XML level.
The problem with the following VBS code is that it doesn't encounter any projects (as all of them are contained in Solution Folders) - instead, I'm just getting a list of the Solution Folders.
Example msgbox output:
NAME:Gateways TYPE: {66A26720-8FB5-11D2-AA7E-00C04F688DDE}
The above GUID is actually the same for all solution folders.
solutionfile = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName) + "\big_solution.sln"
msgbox(solutionfile)
Set dte = CreateObject("VisualStudio.DTE.9.0")
dte.MainWindow.Visible = True
Call dte.solution.open(solutionfile)
Set prjs = DTE.Solution.Projects
For i = 1 To prjs.Count
Set p = prjs.Item(i)
msgbox("NAME:" & p.Name & " TYPE: " & p.Kind & vbCr)
Next
Call dte.solution.SaveAs(dte.solution.FileName)
dte.solution.close
msgbox solutionfile + " successfully updated."
dte.UserControl = True
Thanks for any hints!
To work with VS2008 solutions, you need first of all
but it does not expose all properties of all kinds of projects (e.g. the property "InheritedPropertySheets" in C++ projects is not accessible). To access C++ projects properly you will also need:
Example in C# (.NET 3.5) which traverses a solution, making sure each C++ project inherits our custom Property Sheet and then in the Post-Build Step uses the macro "THETARGETDIR" which is defined centrally in our Property Sheet.
App.config:
ourbuild.vsprops