• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 838
  • Last Modified:

Clean and Rebuild Macro problem

I'm trying to create a macro that will perform a Clean Solution ad then a Rebuild Solution.
When recording a macro doing so it creates:

Public Module RecordingModule

    Sub TemporaryMacro()
        DTE.ExecuteCommand("Build.CleanSolution")
        DTE.ExecuteCommand("Build.RebuildSolution")
    End Sub
End Module

Open in new window


When I run this, I get the following error (after cleaning the solution)

An exception of type 'System.Runtime.InteropServices.COMException' occurred in VBAssembly but was not handled in user code

Additional information: Et kald til en COM-komponent returnerede fejlen HRESULT E_FAIL.

I tried inserting a Threading.Thread.Sleep() but that didn't help.

Any suggestions ?



0
fc_curling
Asked:
fc_curling
  • 4
  • 4
1 Solution
 
fc_curlingAuthor Commented:
How come no one have responded yet ?

0
 
DanRollinsCommented:
Build.RebuildSolution
automatically does a Clean before starting the build.
http://www.codekicks.com/2009/06/difference-between-build-solution-and.html
0
 
fc_curlingAuthor Commented:
@DanRollins

No it doesn't.
Rebuild forces a rebuild on all projects in the solution, it doesn't make a cleanup of the bin folder first.
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
fc_curlingAuthor Commented:
Full points available for a solution-
0
 
DanRollinsCommented:
I don't know why the error occurs, but what I said stands.  
Try it.  Note that the timestamp changes on the DLLs and other files in the BIN folder that are normally deleted by Clean.  They (all of them) are rebuilt during the Rebuild process.
0
 
DanRollinsCommented:
This works...

        DTE.Solution().SolutionBuild().Clean(True)
        DTE.Solution().SolutionBuild().Build(True)

Open in new window


Apparently the Build.CleanSolution command runs asynchronously.  By using the above, you can set the "wait for done" option and that prevents the error.
0
 
fc_curlingAuthor Commented:
Perfect Dan, just what I needed.

Do you have any links to any programming references for developing VS Macros and/or AddIns?
0
 
DanRollinsCommented:
No.  I just googled and tested.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now