16

When I press run button in Rider (net core) it run the following command:

/usr/local/share/dotnet/dotnet /pathtomyproject/myproject.dll

But I need to run the project with the argument "watch", if I write this command in Rider Edit Configurations's arguments I got error:

Unhandled Exception: System.FormatException: Unrecognized argument format: 'watch'.

I know to run with watch tool is dotnet watch run, and I know too that I can run that command in the terminal.

My question is if I can configure Rider to run this way when I press Run button? or... maybe Rider has an Edit and Continue feature that I don't know?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Yuri Morales
  • 2,351
  • 4
  • 25
  • 52

2 Answers2

22

There is an answer on Rider forum: https://rider-support.jetbrains.com/hc/en-us/community/posts/360001346139-Simpler-integration-for-Microsoft-DotNet-Watcher-Tools

In short:

  1. Open Run Configurations dialog
  2. Add new "Before launch" configuration
  3. Select "External tool"
  4. Fill in "Tool settings" section (see the link above)

Edit

The external tool settings should be:

  • Program: c:\program files\dotnet\dotnet.exe
  • Arguments: watch run
  • Working directory: <path to your project folder>
decocijo
  • 908
  • 7
  • 19
Julia Vaseva
  • 456
  • 3
  • 7
  • 7
    It would be nice to have an option to attach debugger to running `dotnet watch run` task. Now i'm switching between two configurations. Default one for debugging and second one for continuous building without debugging. – lukyer Mar 23 '18 at 12:22
  • 7
    The link is no longer available – Ofiris Dec 02 '18 at 12:28
  • 2
    The link changed to: https://rider-support.jetbrains.com/hc/en-us/community/posts/360001346139-Simpler-integration-for-Microsoft-DotNet-Watcher-Tools (I updated the answer with the new link) – decocijo May 26 '20 at 07:29
  • For the working directory, you can use `$SolutionDir$$SolutionName$` to point to your startup project directory without hardcoding paths – Tomasz Juszczak May 23 '21 at 12:54
5

You can use the "Native Executable" option as a run configuration to make this happen. To do so:

  1. Select Run -> Edit Configuration from the menu options

  2. Click the + icon and select the "Native Executable" option from the list.

  3. In the options that are displayed, provide the following...

    • Name: Watch (or whatever you prefer)
    • Exe path: /usr/local/share/dotnet/dotnet
    • Program Arguments: watch run
    • Working directory: [path to your project where .csproj file resides]
  4. Click "OK" to apply/save the changes.

  5. When ready, select Run -> Run... from the menu options. Select the "Watch" option.

You should see the terminal results build/run the app. If you change your controller file, you'll see the file change detected and the app rebuild.

Dillie-O
  • 29,277
  • 14
  • 101
  • 140
  • I don't know what is your Rider version, but mine (latest) there is no Native Executable option. (macOS) – Yuri Morales Feb 19 '19 at 14:34
  • 1
    @YuriMorales I'm using 2018.3 (Mac) - Here's what I see in my Run/Debug Configurations that I built: https://www.evernote.com/l/ACI63LpG4vVKaYRtVjELVVKiKkf-xRS1d5c – Dillie-O Feb 20 '19 at 17:22