Utilizing Pre-Build and Post-Build Events RRS feed

  • Question

  • Using VS2003 - C# I've built an application that consists of a WinForms app and a Windows Mobile app.  I have a series of steps I take to compile a new setup package.  I'm content with this process, even if it isn't a one-click process.

    But I'm about to expand things by introducing two additional WinForms app compilations - one for a trial version and one for a special read-only version.  In order to accomplish this I'm going to need to constantly update a few properties in assorted text files such as App.config.

    I've been researching the easiest way to do this automatically and am thinking that perhaps using the pre-build and post-build events that I see in the Project Properties is the answer.

    To this end, I have some questions:
    1. Would you agree that this is the best approach or would you suggest another?
    2. If the former then into the pre/post build textboxes, am I to enter an EXE that I've specially built for this purpose?

    Robert W.
    Saturday, March 17, 2007 1:31 AM


  • There are several ways of doing this:

    - one is to use those pre/post build events, but they require an external app to modify settings, which will cause the warning "the document was modified outside the editor. Do you want to reload it?" or similar.

    - other is to use VS automation to capture the EnvDTE.BuildEvents. See:

    HOWTO: Canceling a build from a Visual Studio .NET add-in.


    - another is to capture the build commands, not the build events. See:

    HOWTO: Capturing commands events from Visual Studio .NET add-ins


    - yet another is to provide your own commands to initiate the build rather than capturing build events. See:

    Automating Builds and Configurations in Visual Studio .NET





    Saturday, March 17, 2007 11:39 AM