Partilhar via


How to: Specify Pre- and Post-Instrument Commands

Note

This article applies to Visual Studio 2015. 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.

Requirements

  • Visual Studio Ultimate, Visual Studio Premium, Visual Studio Professional

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

    32-bit computers

    On 32-bit computers, the default profiler tools directory is Drive\Program Files\Microsoft Visual Studio 10.0\Team Tools\Performance Tools.

    64-bit computers

    On 64-bit computers, specify the path according to the target platform of the profiled application:

  • For 32-bit applications, the default profiler tools directory is:

    Drive\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Performance Tools

  • For 64-bit applications, the default profiler tools directory is:

    Drive\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Performance Tools\x64

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

Configuring Performance Sessions