Build Automation and DTE-Object

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Michael Engelmann (engelmann_m_at_annotext.de)
Date: 09/29/04


Date: 29 Sep 2004 09:49:11 -0700

Hi

I have 2 questions and no answers....

1.
How can I get the Value of the $TargetName Macro (from the
project-properties) in the DTE.Object?

DTE.Solution.Solutionbuild.??????

2.
I want do build some Solutionions one after the other. Ok, I can make
a big Solution an insert all Solutions to build in it. But this way is
<censored>.

I want to open the first solution, build them, if build is ok, close,
open a new solution, and so on. So I wrote a macro to do this:

Imports EnvDTE
Imports System.Diagnostics

Public Module ScriptTest
  Dim WithEvents bldevents As BuildEvents
  Dim WithEvents solevents As SolutionEvents
  Dim applicationObject As EnvDTE.DTE

  Sub TestModal()
    DTE.ExecuteCommand("View.ResourceView")
    DTE.ExecuteCommand("View.SolutionExplorer")
    DTE.ExecuteCommand("View.Output")

    DTE.Solution.Open("FirstSolution.sln")
    SetBuildEvent()
    SetCloseEvent()
    ScriptSetConfiguration("Release")
    DTE.Solution.SolutionBuild.Build()
  End Sub

  private Sub NextSolution()
    DTE.Solution.Open("SecondSolution.sln")
    SetBuildEvent()
    SetCloseEvent()
    ScriptSetConfiguration("Release")
    DTE.Solution.SolutionBuild.Build()
  End Sub

  Private Sub solevents_AfterClosing() Handles solevents.AfterClosing
    NextSolution()
  End Sub

  Private Sub bldevents_OnBuildDone(ByVal Scope As
EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles
bldevents.OnBuildDone
    DTE.Solution.Close()
  End Sub

  Private Sub ScriptSetConfiguration(ByVal ActiveConfig As String)
    Dim sb As SolutionBuild
    Dim config As SolutionConfiguration
    Dim context As SolutionContext

    sb = DTE.Solution.SolutionBuild
    config = sb.ActiveConfiguration
    For Each context In config.SolutionContexts
      context.ConfigurationName = ActiveConfig
      context.ShouldBuild = True
    Next
    DTE.Windows.Item(Constants.vsWindowKindOutput).Activate()
  End Sub

  Private Sub SetBuildEvent()
    applicationObject = CType(Application, EnvDTE.DTE)
    bldevents = CType(applicationObject.Events.BuildEvents,
EnvDTE.BuildEvents)
  End Sub

  Private Sub SetCloseEvent()
    applicationObject = CType(Application, EnvDTE.DTE)
    solevents = CType(applicationObject.Events.SolutionEvents,
EnvDTE.SolutionEvents)
  End Sub
End Module

It works fine.......
for the first solution. If it has to open the Second Solution, the IDE
opens something, but not the whole SecondSolution (the menu
File->CloseSolution is grayed), only the Project is opend.

Is it not possible to open a new Solution, after closing a solution,
using Events?

I use Framework 1.1, Development Enviroment 2003

Michael



Relevant Pages

  • Re: how do i play wav over tapi3 (vb.net)
    ... Regarding TAPI and .NET see KB article ... Public Sub New ... Private Sub InitializeComponent() ... Dim WithEvents gObjTapiWithEvents As TAPI ...
    (microsoft.public.win32.programmer.tapi)
  • Re: Code looping through files
    ... Sub AllFolderFiles() ... Dim TheFile As String ... in a folder, opens each, does things, closes the file ...
    (microsoft.public.excel.programming)
  • Re: Code looping through files
    ... Dim myName As String ... Sub AllFolderFiles() ... Professional and I am using Excel 2003 Professional with Windows XP Media ... in a folder, opens each, does things, closes the file ...
    (microsoft.public.excel.programming)
  • Draw lines and icons on a form?
    ... I want to draw on the picturebox some vertical lines and some icons ... Private Sub DrawArea ... Dim XStart As Long, xEnd As Long ... Then Exit Sub ...
    (microsoft.public.vb.general.discussion)
  • Re: Email address from AD
    ... Private Sub InitializeComponent() ... Private Sub Page_Init(ByVal sender As System.Object, ... Dim txtSam As String ... Dim cResult As SearchResultCollection ...
    (microsoft.public.dotnet.languages.vb)