Pre-build Event / Post-build Event Command Line Dialog Box (Database Projects)

In the Build Events pane, you can create pre-build events or post-build events by typing directly in the Pre-build event command line or Pre-build event command line boxes. You can also click Edit Pre-build or Edit Post-build and then specify one or more pre-build and post-build macros from a list of available macros.

Note

Pre-build events do not run if the project is up to date and no build is triggered. You control post-build events by clicking an option in the Run the post-build event list on the Build Events pane.

  • Pre-build event command line and Post-build event command line
    Contains the events to run either before or after the build.

    Note   Add a call statement before each post-build command that runs a .bat file. For example, you can add call C:\MyFile.bat or call C:\MyFile.bat call C:\MyFile2.bat.

  • Macros
    Shows or hides the list of macros that you can insert as pre-build or post-build events.

  • Macro table
    Lists the available macros and their values. See the next section for a description of each. You can click only one macro at a time to insert as a pre-build or post-build event.

  • Insert
    Inserts the specified macro as a pre-build or post-build event.

Macros

You can use any of the macros in the following table to specify file locations or to get the actual names of the input files in the case of multiple selections. These macros are not case-sensitive.

Macro

Description

$(Configuration)

The name of the current project configuration (for example, "Default").

$(MSBuildProjectName)

The base name of the project.

$(MSBuildProjectExtension)

The file extension of the project. It includes the '.' before the file extension.

$(PlatformName)

The name of the currently targeted platform (for example, "AnyCPU").

$(OutputPath)

The path name of the primary output file for the build (defined with drive, path, base name, and file extension).

$(OutputType)

The output type of the project. For database projects, this type is "database".

$(DBProduct)

The version of SQL Server that the database project is targeting. This result will be either SQL Server 2008 or SQL Server 2005.

$(TargetDatabase)

The name of the target database.

$(TargetConnectionString)

The connection string that is used to connect to the server on which the target database resides (or will reside).

$(MSBuildBinPath)

The path of the MSBuild binaries (for example, C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727).

$(DefaultSchema)

The default schema for unqualified objects.

$(SolutionDir)

The directory of the solution (defined with drive and path). This result includes the trailing backslash '\'.

$(SolutionPath)

The absolute path name of the solution (defined with drive, path, base name, and file extension).

$(SolutionName)

The base name of the solution.

$(SolutionFileName)

The file name of the solution (defined with base name and file extension).

$(SolutionExt)

The file extension of the solution. This result includes the '.' before the file extension.

$(DevEnvDir)

The installation directory of Visual Studio 2005 (defined with drive and path). This result includes the trailing backslash '\'.

See Also

Tasks

How to: Specify Custom Actions That Run Pre-build or Post-build

How to: Deploy Changes to New or Existing Databases

Concepts

An Overview of Database Build and Deployment

Writing and Changing Database Code