DEV Community

Alexandru Bucur
Alexandru Bucur

Posted on

How to enable dotnet watch in Jetbrains Raider

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.

  1. Under Run/Debug Configurations, click the plus sign and pick Run external tool
    Run/Debug Configurations

  2. Set dotnet-watch, and make sure to set the proper Working Directory macro $ProjectFileDir$
    External tool

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();
        }
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (5)

Collapse
 
seankilleen profile image
Sean Killeen

Hey! I've noticed that in this post you use "guys" as a reference to the entire community, which is not made up of only guys but a variety of community members.

I'm running an experiment and hope you'll participate. Would you consider changing "guys" to a more inclusive term? If you're open to that, please let me know when you've changed it and I'll delete this comment.

For more information and some alternate suggestions, see dev.to/seankilleen/a-quick-experim....

Thanks for considering!

Collapse
 
coolgoose profile image
Alexandru Bucur

Hi Sean

Thank you for the initiative but as long as "guys" as per o ford's dictionary means a group of people I feel this is just wasted time that diverts from the actual problems in he community when it comes to gender equality.

Collapse
 
seankilleen profile image
Sean Killeen

I speak to that in my post, but if you truly feel strongly enough to not change one word, then I'll have to accept that. Disappointing, but thanks for the response.

Collapse
 
lawlessheaven profile image
Robert Grants

People understand "guys" in the second person plural to be gender neutral. Using "hey guys" and "you guys" (or even "guys" as short hand when in the second person) is use to address all men, all women, or mixed-gender groups. There is no issue with using it, therefore.

Collapse
 
bentoaldo profile image
BentoAldo

Is this still valid for dotnet core 3.1?