?
Solved

Clean and Rebuild Macro problem

Posted on 2011-02-24
8
Medium Priority
?
823 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 

Author Comment

by:fc_curling
ID: 35000241
How come no one have responded yet ?

0
 
LVL 49

Expert Comment

by:DanRollins
ID: 35089496
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
ID: 35111936
@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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 

Author Comment

by:fc_curling
ID: 35111949
Full points available for a solution-
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 35114622
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 2000 total points
ID: 35124441
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
ID: 35132426
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
ID: 35133805
No.  I just googled and tested.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

770 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