Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

How to: Specify a Pre-build or Post-build Command Line

If you must perform actions before or after the database project is built and deployed, you can perform them by specifying a pre-build or post-build command line. You specify these command lines by using the project properties. As examples, you might use a pre-build or post-build command line in the following scenarios:

  • (Pre-build) To copy a .sql file from a SQLCLR project into the schema objects so that your database project and the SQLCLR project are synchronized.

  • (Post-build) To archive build results, compress the build results, or run XSD.EXE to update your DataSet classes.

To specify a pre-build command line

  1. In Solution Explorer, right-click the database project for which you want to specify a pre-build command line, and click Properties.

  2. In the Project Properties window, click the Build Events tab.

  3. Do one of the following:

    1. If you know the command line that you want to execute, in Pre-build event command line, type the command line that you want to execute before the database project is built, and then go to step 5.

    2. If you want to use build macros, click Edit Pre-build. In the Pre-build Event Command Line dialog box, type the command line that you want to execute. You can click a macro in the list and click Insert to insert the macro into your command line.

  4. When you have finished editing the command line, click OK.

  5. On the File menu, click Save Selected Items to save the changes that you made to the project properties.

    The next time that you build the database project, the command line is executed before the database project is built.

To specify a post-build command line

  1. In Solution Explorer, right-click the database project for which you want to specify a post-build command line, and click Properties.

  2. In the Project Properties window, click the Build Events tab.

  3. Do one of the following:

    1. If you know the command line that you want to execute, in Post-build event command line, type the command line that you want to execute after the database project is built, and then go to step 5.

    2. If you want to use build macros, click Edit Post-build. In the Post-build Event Command Line dialog box, type the command line that you want to execute. You can click a macro in the list and click Insert to insert the macro into your command line.

  4. When you have finished editing the command line, click OK.

  5. If you want to run the command line only if the build was successful, in the Run the post-build event list, click On successful build. If you always want the command line to run even if the build fails, in the Run the post-build event list, click Always.

  6. On the File menu, click Save Selected Items to save the changes that you made to the project properties.

    The next time that you build the database project, the command line is executed after the database project is built.

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.