Problem
Running a script with macros using Rider's Run Configuration cannot be directly saved and shared via version control (Git). This limitation affects the use of macros such as $ProjectDir$ or $SolutionDir$ in shell scripts or external tools within Run Configurations.
Resolution
Recommended Solution
Set up a portable configuration by using a script file located inside the project directory. Use Rider's Shell Script Run Configuration with a relative path using $PROJECT_DIR$ to ensure compatibility among team members.
Steps
-
Add the Script to the Repository
-
Place the script file inside your project's repository. For example:
tools/clean-before-run.cmdExample script content (Windows Command Prompt):
@echo off if exist ".\MyFolderToDelete" ( rmdir /S /Q ".\MyFolderToDelete" )If PowerShell is preferred:
Remove-Item -Recurse -Force .\MyFolderToDelete
-
-
Create a Shell Script Run Configuration in Rider
- Go to Run | Edit Configurations.
- Click + and select Shell Script.
- Configure the following settings:
- Execute:
Script file - Script path: Point to
tools/clean-before-run.cmdin your project directory. - Working directory: Set to your project root directory.
- Enable Store as project file.
- Execute:
- Save the configuration.
The paths will internally use
$PROJECT_DIR$, ensuring portability, e.g.,<option name="SCRIPT_PATH" value="$PROJECT_DIR$/tools/clean-before-run.cmd" /> -
Integrate the Script with Run Configuration
- Open the Application Run Configuration.
- In Before Launch, add Run Another Configuration and select the Shell Script configuration created earlier.
- Save the .NET configuration.
-
Share Configuration via Git
- Commit the following files to your repository:
- The script file: e.g.,
tools/clean-before-run.cmd - The Shell Script Run Configuration file stored in
.idea/runConfigurations/. - The .NET Application Run Configuration file stored in
.idea/runConfigurations/.
- The script file: e.g.,
- Commit the following files to your repository:
Comments
0 comments
Please sign in to leave a comment.