---
title: "The Dotnet Watch Tool Revisited - Muhammad Rehan Saeed"
description: "The dotnet watch tool is a file watcher for dotnet that restarts the application when changes in the source code are detected. You can use dotnet watch in Visual Studio by using the launchSettings.json configuration file."
canonical_url: "https://rehansaeed.com/the-dotnet-watch-tool-revisited/"
last_updated: "2018-04-30T00:00:00+00:00"
meta:
  author: "Muhammad Rehan Saeed"
  keywords: ".NET,ASP.NET Core,.NET Boxed,ASP.NET MVC,dotnet watch,launchSettings.json,Visual Studio"
  "og:description": "The dotnet watch tool is a file watcher for dotnet that restarts the application when changes in the source code are detected. You can use dotnet watch in Visual Studio by using the launchSettings.json configuration file."
  "og:image": "https://rehansaeed.com/_og/s/o_f45248c63cfa7334.png"
  "og:image:alt": "The Dotnet Watch Tool Revisited - Muhammad Rehan Saeed"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "The Dotnet Watch Tool Revisited"
  "twitter:image": "https://rehansaeed.com/_og/s/o_f45248c63cfa7334.png"
  "twitter:image:alt": "The Dotnet Watch Tool Revisited - Muhammad Rehan Saeed"
---

> Index of every page on this site: [llms.txt](https://rehansaeed.com/llms.txt)

# [The Dotnet Watch Tool Revisited](https://rehansaeed.com/the-dotnet-watch-tool-revisited/)

Posted 30 April 2018 - **2 min read**

![Microsoft .NET](https://rehansaeed.com/_ipx/f_png&s_2560x1440/images/hero/Microsoft-.NET-1366x768.png)

I talked about using the [dotnet watch tool](https://rehansaeed.com/the-dotnet-watch-tool/) with Visual Studio some time ago. Since then, a lot changed with the Visual Studio tooling and .NET Core 2.0 which broke the use of `dotnet watch` in Visual Studio, hence the reason for writing this post.

The `dotnet watch` tool is a file watcher for .NET that restarts the application when changes in the source code are detected. This is super useful when you just want to hack away at code and see the changes instantly when you refresh your browser. It increases productivity and reduces the magical inner-loop which reduces the time taken to write some code and then see it's effects. I also like using this tool because it opens a console window which lets you see all of your logs flashing by.

![Dotnet Watch Run Console](https://rehansaeed.com/_ipx/f_png&s_2006x978/content-images/posts/2018/the-dotnet-watch-tool-revisited/images/Dotnet-Watch-Run-Console.png)

Warning

In both cases you have to be careful to start the application by clicking `Debug -> Start Without Debugging` or hitting the `CTRL+F5` keyboard shortcut.

# .NET Core 2.0 vs 2.1 Link to this section

Setting up the 'dotnet watch' tool is as easy as installing the `Microsoft.DotNet.Watcher.Tools` NuGet package if you are using .NET Core 2.0. If you are using .NET Core 2.1 or above, this tool comes pre-installed in the .NET Core SDK.

Now using powershell, you can navigate to your project folder and run the `dotnet watch run` command and your set. But using the command line is a bit lame if you are using Visual Studio, we can do one better.

# launchSettings.json Link to this section

The `launchSettings.json` file is used by Visual Studio to launch your application and controls what happens when you hit `F5`. It turns out you can add additional launch settings here to launch the application using the `dotnet watch` tool. You can do so by adding a new launch configuration as I've done at the bottom of this file:

```json
{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:5000/",
      "sslPort": 44300
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "http://localhost:5000/",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development",
        "ASPNETCORE_HTTPS_PORT": "44300"
      }
    },
    "dotnet run": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "http://localhost:5000/",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development",
        "ASPNETCORE_HTTPS_PORT": "44300"
      }
    },
    // dotnet watch run must be run without the Visual Studio debugger using CTRL+F5.
    "dotnet watch run": {
      "commandName": "Executable",
      "executablePath": "dotnet",
      "workingDirectory": "$(ProjectDir)",
      "commandLineArgs": "watch run",
      "launchBrowser": true,
      "launchUrl": "http://localhost:5000/",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development",
        "ASPNETCORE_HTTPS_PORT": "44300"
      }
    }
  }
}
```

Notice that I renamed the second launch profile (which already exists in the default template) to `dotnet run` because that's actually the command it's running and makes more sense.

The `dotnet watch` launch profile is running the `dotnet watch run` command as an executable and using the current working directory of the project. Now we can see the new launch profile in the Visual Studio toolbar like so:

![Dotnet Watch in the Visual Studio Toolbar](https://rehansaeed.com/_ipx/f_png&s_2560x810/content-images/posts/2018/the-dotnet-watch-tool-revisited/images/Dotnet-Watch.png)

# .NET Boxed Templates Link to this section

I have updated the [.NET Boxed](https://github.com/Dotnet-Boxed/Templates) family of project templates with this feature built in. Happy coding!

## Web Mentions

[What's this?](https://en.wikipedia.org/wiki/Webmention)

### 0 Linked

### 0 Replies

## GitHub Comments

### 1 Comment

[Comment on GitHub](https://github.com/RehanSaeed/rehansaeed.github.io/issues/120)

[![RehanSaeed](https://avatars.githubusercontent.com/u/2270364?v=4)](https://github.com/RehanSaeed)

### [RehanSaeed](https://github.com/RehanSaeed)

Owner

12 May 2020 (edited 12 May 2020)

[![NoliSJ](https://camo.githubusercontent.com/d9ebc9b2d585a5206067e7d388fffc70cdf675d3363bdfbfeb58eb12d0691f61/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f62613164316136313139393933333434653038316132373036303532333263303f733d393626643d6d6d26723d67)](https://camo.githubusercontent.com/d9ebc9b2d585a5206067e7d388fffc70cdf675d3363bdfbfeb58eb12d0691f61/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f62613164316136313139393933333434653038316132373036303532333263303f733d393626643d6d6d26723d67) **NoliSJ** commented on **2019-05-13 17:35:12**

Good one. Thanks! Very helpful. One thing I noticed: you have to run VS under an admin account so you won't get security-related issues when dotnet run executes the next time around (effect: CTRL+C command cannot run because of missing privilege, same with replacing the existing binaries when rebuild happens)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://rehansaeed.com/#website","@type":"WebSite","description":"Software Developer at Microsoft, YouTuber, Open Source Contributor and Blogger","inLanguage":"en-GB","name":"Muhammad Rehan Saeed","url":"https://rehansaeed.com/","author":{"@id":"https://rehansaeed.com/#identity"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://rehansaeed.com/?search={search_term_string}"},"query-input":"required name=search_term_string"}],"publisher":{"@id":"https://rehansaeed.com/#publisher"}},{"@id":"https://rehansaeed.com/the-dotnet-watch-tool-revisited/#webpage","@type":"WebPage","dateModified":"2018-04-30T00:00:00+00:00","datePublished":"2018-04-30T00:00:00+00:00","description":"The dotnet watch tool is a file watcher for dotnet that restarts the application when changes in the source code are detected. You can use dotnet watch in Visual Studio by using the launchSettings.json configuration file.","name":"The Dotnet Watch Tool Revisited","url":"https://rehansaeed.com/the-dotnet-watch-tool-revisited/","breadcrumb":{"@id":"https://rehansaeed.com/the-dotnet-watch-tool-revisited/#breadcrumb"},"isPartOf":{"@id":"https://rehansaeed.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://rehansaeed.com/the-dotnet-watch-tool-revisited/"]}]},{"@id":"https://rehansaeed.com/#identity","@type":"Person","name":"Muhammad Rehan Saeed","url":"https://rehansaeed.com/about/","image":{"@id":"https://rehansaeed.com/#/schema/image/1"},"sameAs":["https://github.com/RehanSaeed","https://www.linkedin.com/in/muhammad-rehan-saeed","https://stackoverflow.com/users/1212017/muhammad-rehan-saeed","https://www.youtube.com/c/MuhammadRehanSaeed","https://www.twitch.tv/rehansaeeduk"]},{"@id":"https://rehansaeed.com/#publisher","@type":"Organization","logo":"https://rehansaeed.com/images/schema/Publisher-600x60.png","name":"Muhammad Rehan Saeed","url":"https://rehansaeed.com"},{"@id":"https://rehansaeed.com/the-dotnet-watch-tool-revisited/#article","@type":"Article","dateModified":"2018-04-30T00:00:00+00:00","datePublished":"2018-04-30T00:00:00+00:00","description":"The dotnet watch tool is a file watcher for dotnet that restarts the application when changes in the source code are detected. You can use dotnet watch in Visual Studio by using the launchSettings.json configuration file.","headline":"The Dotnet Watch Tool Revisited","inLanguage":"en-GB","url":"https://rehansaeed.com/the-dotnet-watch-tool-revisited/","author":{"@id":"https://rehansaeed.com/#identity"},"image":[{"@type":"ImageObject","url":"https://rehansaeed.com/images/hero/Microsoft-.NET-1366x768.png","caption":"Microsoft .NET","width":"1366","height":"768"}],"isPartOf":{"@id":"https://rehansaeed.com/the-dotnet-watch-tool-revisited/#webpage"},"keywords":[".NET","ASP.NET Core",".NET Boxed","ASP.NET MVC","dotnet watch","launchSettings.json","Visual Studio"],"mainEntityOfPage":{"@id":"https://rehansaeed.com/the-dotnet-watch-tool-revisited/#webpage"},"publisher":{"@id":"https://rehansaeed.com/#publisher"}},{"@id":"https://rehansaeed.com/the-dotnet-watch-tool-revisited/#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Blog","item":"https://rehansaeed.com/","position":1},{"@type":"ListItem","name":"The Dotnet Watch Tool Revisited","item":"https://rehansaeed.com/the-dotnet-watch-tool-revisited/","position":2}]},{"@id":"https://rehansaeed.com/#/schema/image/1","@type":"ImageObject","contentUrl":"https://rehansaeed.com/images/author/Muhammad-Rehan-Saeed/Logo-512x512.png","inLanguage":"en-GB","url":"https://rehansaeed.com/images/author/Muhammad-Rehan-Saeed/Logo-512x512.png"}]}
```

## Sitemap

See the full [sitemap](https://rehansaeed.com/sitemap.md) for all pages.
