---
title: "The Dotnet Watch Tool - 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."
canonical_url: "https://rehansaeed.com/the-dotnet-watch-tool/"
last_updated: "2016-09-10T00:00:00+00:00"
meta:
  author: "Muhammad Rehan Saeed"
  keywords: ".NET,ASP.NET Core,ASP.NET MVC,.NET Boxed,dotnet watch,launchSettings.json,project.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."
  "og:image": "https://rehansaeed.com/_og/s/o_0ab7aad1cb3a9e6a.png"
  "og:image:alt": "The Dotnet Watch Tool - Muhammad Rehan Saeed"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "The Dotnet Watch Tool"
  "twitter:image": "https://rehansaeed.com/_og/s/o_0ab7aad1cb3a9e6a.png"
  "twitter:image:alt": "The Dotnet Watch Tool - Muhammad Rehan Saeed"
---

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

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

Posted 10 September 2016 - **2 min read**

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

The `dotnet watch` tool is a file watcher for .NET that restarts the application when changes in the source code are detected. If you are using IIS Express then, it actually does this restart for you already. The `dotnet watch` tool is only really useful if you like to run your app in the console. I personally like to do this over using IIS Express because I can see all my logs flashing by in the console like the movies which is occasionally useful if you get an exception.

![Dotnet Watch Run Console](https://rehansaeed.com/_ipx/f_png&s_2006x978/content-images/posts/2016/the-dotnet-watch-tool/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.

# project.json Link to this section

Setting up the `dotnet watch` tool is as easy as installing the `Microsoft.DotNet.Watcher.Tools` NuGet package into the tools section of your `project.json` file like so (You may need to manually restore packages as there is a bug in the tooling which doesn't restore packages if you only change the `tools` section):

```json
{
  //...

  "tools": {
    "Microsoft.DotNet.Watcher.Tools": "1.0.0-preview2-final"
    //...
  },

  //...
}
```

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:8080/",
      "sslPort": 44300
    }
  },
  "profiles": {
    // Run the app using IIS Express. Use CTRL+F5 or Debug -> Start Without Debugging to edit code and refresh the browser 
    // to see your changes while the app is running.
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "https://localhost:44300/",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    // Run the app in console mode using 'dotnet run'.
    "dotnet run": {
      "commandName": "Project",
      "commandLineArgs": "--server.urls http://*:8080",
      "launchBrowser": true,
      "launchUrl": "http://localhost:8080/",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    // Use CTRL+F5 or Debug -> Start Without Debugging to use this launch profile. Launches the app using 'dotnet watch', 
    // which allows you to edit code and refresh the browser to see your changes while the app is running.
    "dotnet watch": {
      "executablePath": "C:\\Program Files\\dotnet\\dotnet.exe",
      "commandLineArgs": "watch run --server.urls http://*:8080",
      "launchBrowser": true,
      "launchUrl": "http://localhost:8080/",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}
```

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 `dotnet watch run` but it's also passing in the `server.urls` argument which lets us override the port number. 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/2016/the-dotnet-watch-tool/images/Dotnet-Watch.png)

# .NET Boxed Link to this section

If you read my blog posts, you'll be seeing a trend by now. I built the above feature into the [.NET Boxed](https://github.com/Dotnet-Boxed/Templates) project templates by default so you can create a new project with this feature built-in, right out of the box. Happy coding!

## Web Mentions

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

### 0 Linked

### 0 Replies

## GitHub Comments

### 13 Comments

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

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

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

Owner

12 May 2020

[![Duncan](https://camo.githubusercontent.com/4f83a2e02759faa72eedb0c1bd695f5d48afd3d76d19c6991d974fe8bc3eec4b/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f65636339616136333461303631636464666561323634333531303130383833343f733d393626643d6d6d26723d67)](https://camo.githubusercontent.com/4f83a2e02759faa72eedb0c1bd695f5d48afd3d76d19c6991d974fe8bc3eec4b/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f65636339616136333461303631636464666561323634333531303130383833343f733d393626643d6d6d26723d67) **[Duncan](http://banoffeesolutions.co.uk/)** commented on **2016-09-12 12:07:36**

Useful article!  
 What tool do you use for your blog as it looks clean and efficient?!

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

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

Owner

12 May 2020

[![Muhammad Rehan Saeed](https://camo.githubusercontent.com/8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67)](https://camo.githubusercontent.com/8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67) **[Muhammad Rehan Saeed](https://rehansaeed.com/)** commented on **2016-09-13 08:38:15**

> Useful article!  
>  What tool do you use for your blog as it looks clean and efficient?!

It's Nami WordPress (So I can run on Azure with SQL Server) with a Themify theme.

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

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

Owner

12 May 2020

[![Andrew Lock](https://camo.githubusercontent.com/18da431ee809b9ea81989819eb276d67891c8523b423ad5387ed789948df1a7e/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f38666364343436343531346431396566613931653234663037393534646263633f733d393626643d6d6d26723d67)](https://camo.githubusercontent.com/18da431ee809b9ea81989819eb276d67891c8523b423ad5387ed789948df1a7e/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f38666364343436343531346431396566613931653234663037393534646263633f733d393626643d6d6d26723d67) **[Andrew Lock](https://andrewlock.net/)** commented on **2016-09-15 09:07:26**

Great post - I've generally been using the watcher tool from the command line for all my core work, hooking into the launcher tool makes so much sense!

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

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

Owner

12 May 2020

[![Muhammad Rehan Saeed](https://camo.githubusercontent.com/8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67)](https://camo.githubusercontent.com/8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67) **[Muhammad Rehan Saeed](https://rehansaeed.com/)** commented on **2016-09-15 11:14:37**

> Great post - I've generally been using the watcher tool from the command line for all my core work, hooking into the launcher tool makes so much sense!

Watching the command line just helps so much with debugging sometimes.

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

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

Owner

12 May 2020

[![Mike-EEE](https://camo.githubusercontent.com/073a637e433812126b5ee5a88d9b27ce08c510387a14507f2429287cfae86b16/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f63386561643331323263363239313934636233306437623331636461363962653f733d393626643d6d6d26723d67)](https://camo.githubusercontent.com/073a637e433812126b5ee5a88d9b27ce08c510387a14507f2429287cfae86b16/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f63386561643331323263363239313934636233306437623331636461363962653f733d393626643d6d6d26723d67) **[Mike-EEE](http://blog.developers.win/)** commented on **2016-09-27 18:23:43**

Nice article! BTW, you made The Week in .NET:  
https://blogs.msdn.microsoft.com/dotnet/2016/09/27/the-week-in-net-on-net-on-orchard-2-mocking-on-core-storyteller-armello/

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

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

Owner

12 May 2020

[![Muhammad Rehan Saeed](https://camo.githubusercontent.com/8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67)](https://camo.githubusercontent.com/8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67) **[Muhammad Rehan Saeed](https://rehansaeed.com/)** commented on **2016-09-28 08:36:53**

> Nice article! BTW, you made The Week in .NET:  
> https://blogs.msdn.microsoft.com/dotnet/2016/09/27/the-week-in-net-on-net-on-orchard-2-mocking-on-core-storyteller-armello/

Cool, thanks for the heads up!

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

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

Owner

12 May 2020

[![Manoj Kulkarni](https://camo.githubusercontent.com/cf74ba2a15703985e5ca85c6e0b84a8838708acd2cff0636d55f760fd7632cd4/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f33623938656239626630383265386339663536353735353865373135376632303f733d393626643d6d6d26723d67)](https://camo.githubusercontent.com/cf74ba2a15703985e5ca85c6e0b84a8838708acd2cff0636d55f760fd7632cd4/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f33623938656239626630383265386339663536353735353865373135376632303f733d393626643d6d6d26723d67) **[Manoj Kulkarni](http://dotnetcontext.com/)** commented on **2016-11-04 05:34:09**

Great post. Thank you

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

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

Owner

12 May 2020

[![Danial](https://camo.githubusercontent.com/9521cb6b1c7aae8588ec8d6fb847be15cb03ccc7e191dd668c4984aaa5c4fd7a/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f39323936376635633264313232386435623938333966666262653732316635333f733d393626643d6d6d26723d67)](https://camo.githubusercontent.com/9521cb6b1c7aae8588ec8d6fb847be15cb03ccc7e191dd668c4984aaa5c4fd7a/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f39323936376635633264313232386435623938333966666262653732316635333f733d393626643d6d6d26723d67) **Danial** commented on **2016-11-21 10:06:54**

Thanks for the great article! *thumbs up*

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

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

Owner

12 May 2020

[![saillesh Pawar](https://camo.githubusercontent.com/0b16fbaf66a136ea52d5266b78bb62fece429653aa15a0e60d192315da27db30/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f34613066616132303662633965366536636637343232336662316362333266323f733d393626643d6d6d26723d67)](https://camo.githubusercontent.com/0b16fbaf66a136ea52d5266b78bb62fece429653aa15a0e60d192315da27db30/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f34613066616132303662633965366536636637343232336662316362333266323f733d393626643d6d6d26723d67) **[saillesh Pawar](https://sailleshpawar.wordpress.com/)** commented on **2017-02-15 19:57:15**

Excellent post was thinking how useful it would be if I can do the same visual studio glad you have already done, learned how Visual Studio to launch our application and controls what  
 happens when we hit f5.

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

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

Owner

12 May 2020

[![saillesh Pawar](https://camo.githubusercontent.com/0b16fbaf66a136ea52d5266b78bb62fece429653aa15a0e60d192315da27db30/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f34613066616132303662633965366536636637343232336662316362333266323f733d393626643d6d6d26723d67)](https://camo.githubusercontent.com/0b16fbaf66a136ea52d5266b78bb62fece429653aa15a0e60d192315da27db30/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f34613066616132303662633965366536636637343232336662316362333266323f733d393626643d6d6d26723d67) **[saillesh Pawar](https://sailleshpawar.wordpress.com/)** commented on **2017-02-15 20:21:28**

Hi Rehan while executing the dotnet watch launch profile i am getting below error:

watch : Could not find a MSBuild project file in 'project name'. Specify which project to use with the `--project` option.

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

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

Owner

12 May 2020

[![Muhammad Rehan Saeed](https://camo.githubusercontent.com/8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67)](https://camo.githubusercontent.com/8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67) **[Muhammad Rehan Saeed](https://rehansaeed.com/)** commented on **2017-02-16 10:14:00**

> Hi Rehan while executing the dotnet watch launch profile i am getting below error:
>
> watch : Could not find a MSBuild project file in 'project name'. Specify which project to use with the `--project` option.

You need to hit Ctrl+F5 to use dotnet watch run.

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

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

Owner

12 May 2020

[![Jasonlhy](https://camo.githubusercontent.com/2e35a6928c5f142b8daf42d0f37940c96e9b3b7d713f8734e647f874d521c288/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f30636539363264356266666365656565663638383732323833383331333363613f733d393626643d6d6d26723d67)](https://camo.githubusercontent.com/2e35a6928c5f142b8daf42d0f37940c96e9b3b7d713f8734e647f874d521c288/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f30636539363264356266666365656565663638383732323833383331333363613f733d393626643d6d6d26723d67) **Jasonlhy** commented on **2017-02-28 06:55:02**

Cool, thanks a lot. But it seems that the port number cannot be specified now

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

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

Owner

12 May 2020

[![Muhammad Rehan Saeed](https://camo.githubusercontent.com/8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67)](https://camo.githubusercontent.com/8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca/68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67) **[Muhammad Rehan Saeed](https://rehansaeed.com/)** commented on **2017-02-28 11:05:47**

> Cool, thanks a lot. But it seems that the port number cannot be specified now

What do you mean? Seems to work fine for me. Are you sure you have not hard coded the port number in `Program.cs`?

```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/#webpage","@type":"WebPage","dateModified":"2016-09-10T00:00:00+00:00","datePublished":"2016-09-10T00: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.","name":"The Dotnet Watch Tool","url":"https://rehansaeed.com/the-dotnet-watch-tool/","breadcrumb":{"@id":"https://rehansaeed.com/the-dotnet-watch-tool/#breadcrumb"},"isPartOf":{"@id":"https://rehansaeed.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://rehansaeed.com/the-dotnet-watch-tool/"]}]},{"@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/#article","@type":"Article","dateModified":"2016-09-10T00:00:00+00:00","datePublished":"2016-09-10T00: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.","headline":"The Dotnet Watch Tool","inLanguage":"en-GB","url":"https://rehansaeed.com/the-dotnet-watch-tool/","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/#webpage"},"keywords":[".NET","ASP.NET Core","ASP.NET MVC",".NET Boxed","dotnet watch","launchSettings.json","project.json","Visual Studio"],"mainEntityOfPage":{"@id":"https://rehansaeed.com/the-dotnet-watch-tool/#webpage"},"publisher":{"@id":"https://rehansaeed.com/#publisher"}},{"@id":"https://rehansaeed.com/the-dotnet-watch-tool/#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Blog","item":"https://rehansaeed.com/","position":1},{"@type":"ListItem","name":"The Dotnet Watch Tool","item":"https://rehansaeed.com/the-dotnet-watch-tool/","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.
