Solved

Clean and Rebuild Macro problem

Posted on 2011-02-24
8
809 Views
Last Modified: 2013-11-26
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
Comment
Question by:fc_curling
  • 4
  • 4
8 Comments
 

Author Comment

by:fc_curling
Comment Utility
How come no one have responded yet ?

0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
Build.RebuildSolution
automatically does a Clean before starting the build.
http://www.codekicks.com/2009/06/difference-between-build-solution-and.html
0
 

Author Comment

by:fc_curling
Comment Utility
@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
 

Author Comment

by:fc_curling
Comment Utility
Full points available for a solution-
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
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
 
LVL 49

Accepted Solution

by:
DanRollins earned 500 total points
Comment Utility
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
 

Author Closing Comment

by:fc_curling
Comment Utility
Perfect Dan, just what I needed.

Do you have any links to any programming references for developing VS Macros and/or AddIns?
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
No.  I just googled and tested.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now