locked
How can I get the current "StartUpProject" by MACRO? RRS feed

  • Question

  • Hi,

    I want to get the reference of "StartUpProject"  of solution. There is only existing similar command in VS:  DTE.ExecuteCommand("Project.SetasStartUpProject")

    In Macro, How can I get the "StartUpProject" and "CurrentActiveProject" by using some property?

    Thanks in ahead,

    Bob Zhao

    Saturday, January 1, 2011 11:49 AM

Answers

  • Hi Bob,

     

    Thanks for your post.

    As far as I know, you can get the "StartUpProject" and "CurrentActiveProject" by following lines:

        Public Sub StartUpProj()
            Dim projName As String = DTE.Solution.Properties.Item("StartupProject").Value
            For Each proj As Project In DTE.Solution.Projects
                If proj.Name = projName Then
                    'proj is the StartUpProject
                End If
            Next
        End Sub
        Public Sub SelectedProj()
            Dim proj As Project = DTE.ActiveSolutionProjects.GetValue(0) 'proj is the current active one
        End Sub

    Hope my reply helps resolve your issue.

     

    Best Regards,

    Ziwei Chen

     


    Ziwei Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Victor_Chen Monday, January 10, 2011 7:59 AM
    Monday, January 3, 2011 6:39 AM

All replies

  • Hi Bob,

     

    Thanks for your post.

    As far as I know, you can get the "StartUpProject" and "CurrentActiveProject" by following lines:

        Public Sub StartUpProj()
            Dim projName As String = DTE.Solution.Properties.Item("StartupProject").Value
            For Each proj As Project In DTE.Solution.Projects
                If proj.Name = projName Then
                    'proj is the StartUpProject
                End If
            Next
        End Sub
        Public Sub SelectedProj()
            Dim proj As Project = DTE.ActiveSolutionProjects.GetValue(0) 'proj is the current active one
        End Sub

    Hope my reply helps resolve your issue.

     

    Best Regards,

    Ziwei Chen

     


    Ziwei Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Victor_Chen Monday, January 10, 2011 7:59 AM
    Monday, January 3, 2011 6:39 AM
  • Hi Bob,

     

    Is it resolved?

     

    Best Regards,

    Ziwei Chen

     

     

     


    Ziwei Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, January 10, 2011 7:59 AM
  • Thanks ZiWei! It works well.

    Sunday, February 27, 2011 9:03 AM
  • BTW, I didn't get the alart msg for your reply, even I use hotmail.
    Sunday, February 27, 2011 9:10 AM