Is it possible to control build event batch file behaviour depending on whether the build is run from the IDE or the command line.
We have several versions of our product. It contains COM objects that need to be registered. This COM registration is done by a batch file called from a custom build step in the respective project.
The problem is that if a developer runs an automated build for one version from the command line in the background while working on another version in the IDE the automated build will register the COM objects from the version not being worked on in the IDE.
So, is there a way to control whether the registration takes place depending on if the build is done in the IDE or from the command line using devenv?
Thanks.
I don’t know that VS “knows” how it’s being run. I’d be surprised if there wasn’t something somewhere that flags whether or not it’s being run from the command line, however we may not have any access to that.
Perhaps this can be solved using a build configuration. When you build from the command line, set the build configuration value to a configuration that excludes the COM registration step. I think you should be able to write into your post build batch a test for the appropriate build configuration (I’m almost sure that VS has a build macro value for the current build config) and branch the logic accordingly. Of course, this means each developer needs to be aware of this. Although you could make a batch file in the project for doing these builds which includes the necessary build switches/values.
I’m curious what your scenario is that you have one developer building the same application two different ways simultaneously.