15

I am running ASP.NET Core application on Visual Studio Code on a mac. To run the app, I use dotnet run from the terminal.

Whenever I make changes in one of the C# files, I have to stop and restart the app by hitting ctrl+c first and dotnet run again.

I watched Pluralsight course of Scott Allen, where he uses Visual Studio and after an edit to any C# files, he just reloads the page and it shows the changes. I am wondering if I can do the same in Visual Studio Code.

1
  • If you make HTML or CSS changes you just have to simply save and refresh page, however if you make c# code changes you need to recompile. Commented Nov 7, 2016 at 15:22

1 Answer 1

26

I think that dotnet watch should work. See the documentation from the link as there are various options. Here I copied the order in which this should work.

  1. Add Microsoft.DotNet.Watcher.Tools to the tools section of the project.json file
  2. Run dotnet restore
  3. Execute with dotnet watch run
Sign up to request clarification or add additional context in comments.

4 Comments

That worked, thanks..are the steps same for Visual Studio as well?
@akshayKhot - you might be able to do CTRL+F5, in a full version of VS starts the process without attaching the debugger. I am not sure about VS Code but maybe its the same.
it works but it is very slow - like have to wait around 5 sec - any change to speed up?
Starting from .NET Core 2.1 Preview 2 the CLI tools like dotnet watch are now part of the SDK

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.