VS 2003 Tip #10: Run pre and post build commands from the C# projects

Vs7 customers complained to us that they wanted pre and post build commands that could be run from the project system. Its pretty reasonable to want to automate some tasks that you would do before or after builds, so in Everett we added this in.

To get to this feature take any C# project, and check out the project properties (Project->Properties). Then select Common Properties->Build Events and you should see the property page for custom build steps.

This syntax can include any command that is valid at the command line or in a .bat file. The name of a batch file should be preceded by call to ensure that all subsequent commands will be executed. There are also a handy set of macros to help with the commands. For more information, check out the VS help on this.

For those who might ask, VB doesnt support this in Everett.

Comments

  • Anonymous
    March 26, 2004
    This is very useful, and I have been using it for a while now, but maybe I'm missing something. I would like to be able to only run some post build events if I'm in release mode (for example, obfuscation, or NDoc documentation). Is this possible, or will it be in Whidbey?
  • Anonymous
    March 26, 2004
    Problem though, the feature is not available for web projects. For most peopl this may not be an issue. I have a web project that has BLL/DAL projet that are shared with a Windows Service. It would be nice to be able to stop the service, do the build and then restart the service.
  • Anonymous
    March 26, 2004
    Joel, you write this kind of (ugly) batch file code:

    if not "$(ConfigurationName)"=="Release" goto :finish
    ... something for release...
    :finish