How to enable dotnet watch in Jetbrains Raider
Alexandru Bucur
Posted on March 10, 2018
Hi guys, while working on my pet API project in C# and .NET Core I realized that I miss having the debugger 'watch' for file changes.
The standard way of doing this in .NET Core 2.0 is to setup dotnet-watch . It seems that starting with .NET Core 2.1 this step isn't going to be necessary, so one less step to do.
Until then you can follow the official tutorial for setting up dotnet-watch.
In order to make it work in Rider, you need to do some simple steps.
Under Run/Debug Configurations, click the plus sign and pick Run external tool
Set dotnet-watch, and make sure to set the proper Working Directory macro
$ProjectFileDir$
Update
Since there's no implicit way of setting up the ASPNETCORE_ENVIRONMENT in Rider before running the command, here's a quick way of adding a parameter to your program to enable the switch.
Modify Program.cs
public static IWebHost BuildWebHost(string[] args)
{
var config = new ConfigurationBuilder().AddCommandLine(args).Build();
var enviroment = config["environment"] ?? "Development";
return WebHost.CreateDefaultBuilder(args)
.UseEnvironment(enviroment)
.UseStartup<Startup>()
.Build();
}
Now you can run
dotnet watch run --environment="Development"
(or any other environment variable) and have the specific environment setup depending on your run configuration.
Posted on March 10, 2018
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.