Using Run Configurations
ReSharper helps you create, manage, and execute multiple run configurations for a solution. A run configuration lets you run or debug a project, a static method or any executable file.
In this topic:
- Run Configurations pop-up
- Run Configurations in ReSharper Build & Run
- Active run configuration
- Types of run configurations and their preferences
- Creating and editing run configurations
- Executing run configurations
- Sharing run configurations
Run Configurations pop-up
The pop-up displays all existing run configurations. The active run configuration is highlighted in bold.
Run Configurations in ReSharper Build & Run
You can also execute run configurations in the Build & Run window.
The active run configuration is shown in the combo box on the window toolbar, when you expand the combo box, you will have similar controls as in the Run Configurations pop-up. Besides, you can use toolbar buttons to run or debug the active configuration, with or without rebuilding.
Active run configuration
Among all run configurations, one is always set as 'active'. The active configuration is executed when you press F5 or choose in the main menu. There is a single run configuration (VS Startup) that exists by default and that you cannot remove. This configuration executes the startup project(s) configured in Visual Studio. Initially, it is set as the active configuration.
As soon as you create a new run configuration, the newly created configuration becomes active automatically.
To set another run configuration as active, select it in the Run Configurations pop-up, and then choose .
ReSharper overrides Visual Studio's Start and Start Without Debugging commands (available in the menu or with F5/Ctrl+F5 shortcuts) to execute ReSharper's active configuration. If you need to return to the Visual Studio's configuration, choose VS Startup in the Run Configurations pop-up.
Types of run configurations and their preferences
ReSharper allows you to work with run configurations of three different types. Each configuration is identified by name and has a number of properties specific to its type.
With this configuration type, you can run or debug any executable project in your solution. For a large solution with multiple executable projects, this could be an alternative to searching projects in the Solution Explorer and setting the project that you want to execute as the StartUp project.
This configuration type lets you run or debug any public static method without parameters. You can use this type of configuration for a static method to run or debug any algorithm or subsystem in your codebase. If necessary, you can use console for interactive execution.
For this type, you need to provide the full name of the method (i.e. Project.Class.Method) and optionally, a working directory, architecture, CLR (.NET Framework) version, and a project to build before the execution.
Note that you can execute static methods with a temporary run configuration.
Using this configuration type, you can run or debug any executable file. If you choose the debug command, ReSharper will run the executable and then make Visual Studio attach to the corresponding process. This configuration type helps you create a complex execution setup (e.g. if you are working on a plug-in for another program).
For this type, you need to specify the target executable file and optionally, a working directory, command line arguments as well as whether to build a specific project or the whole solution before execution.
Creating and editing run configurations
An all-purpose way to create a new run configuration is to use the Run Configurations pop-up (Ctrl+Shift+Alt+R).
To create a run configuration of any type
Run Configurations pop-up
and then choose the type of configuration you want to create
(Executable, Static Method, or Launch Project).
If you are creating a run configuration for a project, you can alternatively right-click the project in the Solution Explorer and choose Create Run Configuration.
- In the dialog that opens, specify a name and preferences for the configuration, and then click OK
- The newly created configuration is saved and becomes active. You can press F5 or click Run on the toolbar to execute it.
For static methods, you can also quickly create a run configuration right in the editor.
To create a run configuration for a static method
- Set the caret on the declaration of a public static method without parameters.
- Press Alt+Enter or click the action indicator on the left.
- In the action list that opens, choose Debug and then select any of the items with ellipsis (e.g. Run...)
- In the dialog that opens, ReSharper automatically fills all configuration preferences based on the selected method. If necessary, you can change the name of the configuration and any other preferences.
Save & Execute to create the new configuration and execute it in a way
that you chose on step 3 (run/debug, with/without building).
Alternatively, you can click Execute to run/debug the configuration without saving.
If you want to create a copy of an existing run configuration, select it in the Run Configurations pop-up, and then choose Configure | Duplicate. In the dialog that opens, specify a new name for the copied configuration, change any preferences as required, and click OK to finish.
For static methods, you can edit, duplicate, and remove the associated run configurations right from the editor. You can recognize a static method that has run configuration by the fixes action indicator to its left. Click this indicator or press Alt+Enter and then choose Edit, Duplicate, or Delete actions under the Configure item.
Executing run configurations
Executing active configuration
To run/debug the active configuration, press Ctrl+F5/ F5 or choose in the main menu.
By default the project/solution is rebuilt. You can also execute the active configuration without rebuilding. To do so, press Ctrl+Alt+F5 to run without building or Alt+F5 to debug without building.
If you prefer to execute configurations without building, you can change the default behavior. To do so, choose Don't build by default in the Run Configurations pop-up (Ctrl+Shift+Alt+R). When this option is selected, use Ctrl+F5/ F5 to execute the active configuration without building and Ctrl+Alt+F5/ Alt+F5 if you want to rebuild project/solution before execution.
Executing other configurations
You can execute any existing configuration using the Run Configurations pop-up (Ctrl+Shift+Alt+R). To do so, select the desired configuration in the pop-up, and then choose the proper run/debug command. To execute the Visual Studio's configuration, simply choose VS Startup in the pop-up
Executing run configurations for static methods
ReSharper allows you to execute any public static method without parameters. You can set the caret at such method, press Alt+Enter, choose Debug , and then select the desired run/debug command. Before execution starts, you will see a dialog where you will be able to customize execution parameters. Click Execute to execute the method once, or Save & Execute if you want to reuse this configuration.
If a static method has an associated run configuration, ReSharper displays a fixed action indicator to its left. In this case, no dialog is shown when you execute the method.
Attaching debugger to running configuration
If you need to debug a run configuration, you can start it in a debug mode right away. However, if you execute a run configuration with a Run or Run without building commands, you can attach to it anytime later.
If you have one or more run configurations running, you can attach to the running process by choosing
Attach to [configuration name] in the
Run Configurations pop-up
ReSharper will automatically switch Visual Studio to the debug mode and attach to the process of the selected run configuration, allowing you to break its execution, step, etc.
Sharing run configurations
By default, all run configurations that you create are saved in the 'Solution personal' layer of the ReSharper's layered settings.
If you want to share some run configurations with your team members who work on the same solution, you can move these configurations to the 'Solution team-shared' layer. To do so, select a configuration it in the Run Configurations pop-up (Ctrl+Shift+Alt+R), and choose Configure | Share. To stop sharing a run configuration, choose Configure | Unshare. As soon as you push changes to the shared layer ([SolutionName].sln.DotSettings file) into your VCS and other users pull your change, the shared configuration will be readily available to them.
Note that other team members will be able to modify the shared configuration and the updated version will be available as soon as the 'Solution team-shared' settings layer file is updated through VCS.