473,387 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Cannot stop command line build from AddIn

Hi, I'd like to stop command line build by one project build failed.
To do that I've created simple AddIn (see code below), that works fine
for IDE and does not work for command line.
In the AddIn I have only two non-trivial methods:
In OnConnection I add my event handler to OnBuildProjConfigDone, and in
the event handler I executed Build.Cancel.
In IDE - no problem.
When I execute
>devenv /build mySolution
I see that AddIn works and Build.Cancel is called but the build is
still going.
What I do wrong? Maybe DTE.ExecuteCommand(...) waits for the end of
build in that mode...
Does anybody know how to make DTE.ExecuteCommand executes at the moment
of a call.

public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode, object addInInst, ref
System.Array custom)
{
applicationObject = (_DTE)application;
addInInstance = (AddIn)addInInst;
applicationObject.Events.BuildEvents.OnBuildProjCo nfigDone += new

_dispBuildEvents_OnBuildProjConfigDoneEventHandler (BuildEvents_OnBuildProjConfigDone);
}

public void BuildEvents_OnBuildProjConfigDone(string project, string
projectConfig, string platform, string solutionConfig, bool success)
{
if( !success )
{
applicationObject.DTE.ExecuteCommand("Build.Cancel ", "");
}
}

Thank you,
Alex

Sep 15 '06 #1
1 2701
Hi. I did not received a reply but for those who is interested in this
subject I've found an answer.
The problem is: how to stop a solution build when a project build
failed. It must be done for IDE build and for command line build as
well.

It could be done with a simple AddId (for my I use C#).

For some reason applicationObject.Events.BuildEvents objects could not
be used in "direct" way. You must keep reference to it in a Connect
class scope. Since I keep a reference to a applicationObject, it looks
strange. It looks like applicationObject keeps a weak reference to
applicationObject.Events.BuildEvents... Anyway if you define
BuildEventsClass bec;
in a class scope (not in a method!) and add
bec = applicationObject.Events.BuildEvents as BuildEventsClass;
to OnConnection(...) methods, all the build events work fine.

For unknown for me reasons
applicationObject.DTE.ExecuteCommand("Build.Cancel ", "");
does not work also for a command line build. So, I use cpp exit()
method for command line build and "Build.Cancel" for IDE build.
To do that you must also know the mode your application works in: IDE
or CommandLine.

Below are code snippets:
public class Connect : Object, Extensibility.IDTExtensibility2
{
[DllImport("msvcr71.dll")]
public static extern void exit(int exitCode);

bool isCommandLineMode = false;
private _DTE applicationObject;
private AddIn addInInstance;
BuildEventsClass bec;

public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode, object addInInst, ref
System.Array custom)
{
applicationObject = (_DTE)application;
addInInstance = (AddIn)addInInst;
isCommandLineMode = (connectMode ==
Extensibility.ext_ConnectMode.ext_cm_CommandLine);
bec = applicationObject.Events.BuildEvents as BuildEventsClass;
//must
applicationObject.Events.BuildEvents.OnBuildProjCo nfigDone += new
_dispBuildEvents_OnBuildProjConfigDoneEventHandler (BuildEvents_OnBuildProjConfigDone);
}

public void BuildEvents_OnBuildProjConfigDone(string project, string
projectConfig, string platform, string solutionConfig, bool success)
{
if( !success )
{
if( isCommandLineMode )
{
exit(-5);
}
else
{
applicationObject.DTE.ExecuteCommand("Build.Cancel ", "");
}
}
}
}

I still don't know how to do the same with IDE macro instead of AddIn.
Regards,
Alex
AlexZh wrote:
Hi, I'd like to stop command line build by one project build failed.
To do that I've created simple AddIn (see code below), that works fine
for IDE and does not work for command line.
In the AddIn I have only two non-trivial methods:
In OnConnection I add my event handler to OnBuildProjConfigDone, and in
the event handler I executed Build.Cancel.
In IDE - no problem.
When I execute
devenv /build mySolution
I see that AddIn works and Build.Cancel is called but the build is
still going.
What I do wrong? Maybe DTE.ExecuteCommand(...) waits for the end of
build in that mode...
Does anybody know how to make DTE.ExecuteCommand executes at the moment
of a call.

public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode, object addInInst, ref
System.Array custom)
{
applicationObject = (_DTE)application;
addInInstance = (AddIn)addInInst;
applicationObject.Events.BuildEvents.OnBuildProjCo nfigDone += new

_dispBuildEvents_OnBuildProjConfigDoneEventHandler (BuildEvents_OnBuildProjConfigDone);
}

public void BuildEvents_OnBuildProjConfigDone(string project, string
projectConfig, string platform, string solutionConfig, bool success)
{
if( !success )
{
applicationObject.DTE.ExecuteCommand("Build.Cancel ", "");
}
}

Thank you,
Alex
Sep 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jari Aalto+usenet | last post by:
Hi, Where I can specify more linking search directories for a Python module that makes a gcc build? Setting the LD_LIBRARY_PATH on command line does not seem to propagate to the linker. Jari...
2
by: c duden | last post by:
I am able to add an exisiting office addin project to a blank solution in VS.NET 2003. When I attempt to add it's setup project I get the following error in VS.NET "Cannot change threading mode...
1
by: JBMC | last post by:
Hi, I've just installed ASP.NET 1.1 (I have previously been using 1.0). Now I am unable to create a new asp.net application in VS.NET. The problems is as follows..... It appears that the...
5
by: clsmith66 | last post by:
I've been asked to find out if a project is possible, but I'm not having much luck finding the information I need, I hope some one can help. I need to see if I can build a windows service on the...
0
by: AlexZh | last post by:
Hi! I saw a number of topics about the problem, however I still have troubles. Each time I join /command and /build keys in the same command line I receive error message: Not enough storage is...
6
by: epz | last post by:
There is any tool for write & test & execute querys via command line like the old dbase IV style or the sql analyzer tool? (from the Sql Server Database System) Thanks. Eric
5
by: qazwart | last post by:
I am reading from a "cvs rlog" command, and I need both the STDOUT and STDERR. Unfortunately, something very strange is happening. If I do this: $cmd = "$cvs_cmd -q rlog -NS...
4
by: GHUM | last post by:
The compile works, BUT linking fails: 2.5\Release\psycopg\_psycopg.def -Lc:\python25\libs -Lc: \python25\PCBuild -Lc:/p ostgres/83RC2/lib -lpython25 -lpq -lws2_32 -ladvapi32 -o build...
7
by: Jwe | last post by:
Hi, I've written a program which has both a command line interface and Windows form interface, however it isn't quite working correctly. When run from command line with no arguments it should...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.