Compartilhar via


How to: Specify pre- and post-instrument commands

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

You can specify commands that run before or after the binaries in a performance session are instrumented. Any command that can be issued from the command line can be specified as a pre-instrument or a post-instrument event. For example, you can specify commands that automate the resigning of an assembly with a strong name key in a batch file that is executed after the binaries are instrumented.

You can specify commands for all instrumented binaries in the profiling run or for individual binaries. However, you can specify only one pre-instrument command to run before and only one post-instrument command to run after the instrumentation process. You cannot specify commands for both all binaries and for individual binaries. When you specify commands for all binaries, the commands are run before or after the instrumentation of each binary in the session.

The working directory in which the commands are executed depends on the operating system where you are running Visual Studio and on the target platform of the profiled application.

To get the path to the profiling tools, see Specify the path to command line tools.

To specify pre-instrument commands

  1. Perform one of the following steps:

    • To specify pre-instrument commands for all binaries in a performance session, select the performance session node in Performance Explorer, and then right-click and select Properties.

    • To specify pre-instrument commands for a specific binary, right-click the name of the binary in the Targets list of the performance session, and then select Properties.

  2. In the Property Pages, click Instrumentation.

  3. Type the command in the Command line text box under Pre-Instrument events.

    Note

    You can click the ellipsis button (...) that is adjacent to the Command line box to browse to and select the appropriate .exe, .cmd, or .bat file.

  4. Click OK.

    To disable the command from running without removing it, select the Exclude from instrumentation check box. To modify compiler or linker settings, use the project property pages.

To specify post-instrument commands

  1. Perform one of the following steps:

    • To specify post-instrument commands for all binaries in a performance session, select the performance session node in Performance Explorer, and then right-click and select Properties.

    • To specify post-instrument commands for a specific binary, right-click the name of the binary in the Targets list of the performance session, and then select Properties.

  2. In the Property Pages, click Instrumentation.

  3. Type the command in the Command line text box under Post-Instrument events.

    Note

    You can click the ellipsis button (...) that is adjacent to the Command line box to browse to and select the appropriate .exe, .cmd, or .bat file.

  4. Click OK.

    To disable the command from running without removing it, select the Exclude from instrumentation check box. To modify compiler or linker settings, use the project property pages.

See also

Configure performance sessions