Hi,
I can't seem to get the following macro to work:
Sub BuildProject()
DTE.Solution.Create("C:\\", "MyTestSolution")
DTE.Solution.SaveAs("C:\\MyTestSolution")
DTE.Solution.AddFromFile("C:\\test.vcproj")
DTE.Solution.AddFromFile("C:\\anothertest.vcproj")
If (DTE.Solution.Projects.Count > 1) Then
Dim myproj As EnvDTE.Project
myproj = DTE.Solution.Projects.Item(1)
If Not (myproj Is Nothing) Then
DTE.Solution.SolutionBuild.ActiveConfiguration.Activate()
DTE.Solution.SolutionBuild.BuildProject(DTE.Solution.SolutionBuild.ActiveConfiguration.Name, myproj.Name, False)
End If
End If
End Sub
I can confirm that the ActiveConfiguration name in this case does exist so
it shouldn't fail.
Mirko Matytschak - 10 Jan 2006 16:07 GMT
I'm not shure, but I think the index must be zero:
myproj = DTE.Solution.Projects.Item(0)
Mirko
> myproj = DTE.Solution.Projects.Item(1)
Dustin Campbell - 10 Jan 2006 17:56 GMT
Actually, collections in Visual Studio automation are 1-based because they
were originally designed to be used with VBA.
-----
Best Regards,
Dustin Campbell
Developer Express Inc