HowTo run flexible Build Commands (e.g. some macro)?

Hi,

I have written some .NET 2003-Add-in in Visual Basic and want to provide some customized, build-like services for developers. Customized means here system integration in our special landscape. Build-like means that they are developer's code-dependant and must not lose sight of build time (duration is about minutes/hours not milliseconds...). Command-line tools for that services are available.

I want to provide the services within the VS IDE: When my code/tools is/are running...

  1. ... user interactions like browsing and editing should still be possible
  2. ... all windows - and especially the output window must be refreshed s.t. the re-directed output can be seen while interacting
  3. ... the IDE must forbid other build commands no matter if triggered by short cuts, push buttons, etc.
  4. Nice-To-Have: ...if the build is cancelled: stop my code/tools...

Of course, even built-in build actions can be triggered without IDE "protection" e.g. by calling them from some little VB macro. So all I want to achieve is having IDE's build command facility for running my own code!

(For a special service that I want to provide it makes sense to combine it with the built-in build process. It should be started after the regular build... So build events may be relevant here...)

What I have been able to solve on my own:

  1. Creating commands, toolbars and icons for the Add-in.
  2. Reacting on build events.
  3. Running external programs/system-calls and redirecting their stdout to the output pane.
  4. Raising build events and thus run build commands on projects or project items within the solution.

Combining the methods I have big drawbacks:

  1. When running/calling my own methods in any direct way the IDE still allows build actions. (Makes sense.)
  2. When running my methods within the build event notification the build process has not ended yet (good!) but the IDE "hangs", i.e. does not react and does not refresh anymore. (Makes sense: notification should be fast.)
    Side-effect: Redirecting streams (buffered/synchronized or not) still work very well but the developer cannot see any "progress" and if my Add-in/the tool are working well.
  3. Work-around for the "special" service:
    I listen to the build events. At the end of a "normal" build (post event) I raise a build event for a custom build command, change some internal state and leave post event notification. Here, I lose control and hope that the IDE will process my custom build event next.
    Besides custom build commands have two major limitations:
    a) The custom build command can be maintained in projects or project items only. It can be run only within the current solution. The solution cannot be changed without persisting the project or project item that contains the custom build command. Using the service would mean, that each solution has to be changed itself (i.e. check-out from source control, modified, saved), too!
    b) The custom build command runs command-line tools only. If I want to use studio features when processing the custom build command I would have to attach to the Add-in directly or via a singleton service/daemon, etc.
    All in all the custom build command approach results in very very much overhead for just a disabled control.

In other MS Office programs built-in commands can be overriden easily. Is there a way to do so in VS.NET2003

Help please!

       Martin

How can I break the build, started by the macro
Standard Build.Cancel (Ctrl-break) doesn't work.
Tested in VS.NET2003
Thx a lot fo any help. It's almost perfect now




Answer this question

HowTo run flexible Build Commands (e.g. some macro)?

  • Jack Vaughan

    The only option that you have for overriding existing commands is to connect to the CommandEvents.BeforeExecute event, and return true for the CancelDefault parameter. This will allow you to cancel an event from happening, but the user will still be able to choose Build from one of the menus.

    Commands work differently in Visual Studio than they do in Office Applications (while our command bars look like an Office Application, we are not an Office Application), and programming experiences in one application do not translate to another application.

    Craig



  • HowTo run flexible Build Commands (e.g. some macro)?