I am using code written below..
EnvDTE.DTE dte = (EnvDTE.DTE)Marshal.GetActiveObject("VisualStudio.DTE.12.0");
dte.ExecuteCommand("File.SaveAll"); // Saving all files before building
dte.ExecuteCommand("Build.ReBuildSolution"); // Buidling solution
I want to execute subsequent code statements only after successfull build of solution . Is there any callback defined which notifies successful/unsuccessful build ..
First, if you are using an extension (add-in or package), don't use that way of getting the DTE instance, because Marshal.GetActiveObject(...) returns a running instance of DTE, and if you have two instances of VS open, you could get the wrong instance. The correct way is:
Second, see the article: HOWTO: Performing some action before or after a build from a Visual Studio macro or add-in
The best approach is to use the IVsBuildableProjectCfg.AdviseBuildStatusCallback method to get IVsBuildStatusCallback.BuildEnd called and check the fSuccess parameter.