Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dotnet watch with debug Visual Studio Code

right now my PC is very slow and Visual Studio is working really bad so i decided to try Visual Studio Code to create my ASP.NET Core application. In one of Microsoft presentation I have seen running ASP.NET Core application with tool called dotnet watch. This tool recompile code after some soft changes (like in Visual Studio).

So my quesiton is:

  1. Is there anyway to recompile code in fly in Visual Studio Code after a small change in Debug Mode?
  2. Is there any way to make a task to recompile only one project ? My whole solution has many projects and compiling this every time is just really bad idea.

After I try Debug application with dotnet watch, dotnet enviroment crashing :(

Thanks for help :)

like image 572
mersey Avatar asked Jun 26 '17 21:06

mersey


People also ask

How do I Debug .NET code in Visual Studio Code?

Open the Debug view by selecting the Debugging icon on the left side menu. Select the green arrow at the top of the pane, next to . NET Core Launch (console). Other ways to start the program in debugging mode are by pressing F5 or choosing Run > Start Debugging from the menu.


1 Answers

VS Code: The Visual Studio Code debugger does not support the "Edit and Continue" feature. This feature has been requested (see https://github.com/OmniSharp/omnisharp-vscode/issues/490), however, there are no current plans to implement this in VS Code.

dotnet-watch: if you want to limit which files dotnet-watch watches, then you can alter your ProjectReference's in your *.csproj file.

<ProjectReference Include="..\Other\other.csproj" Watch="false" />

This will ensure dotnet-watch only re-triggers a build on files from the current project, and not files in the project it references.

It won't, however, prevent MSBuild from re-compiling ProjectReferences when it produces a new build. MSBuild will always attempt to recompile all ProjectReferences, though, re-compilation should be fast if you haven't changed files. MSBuild uses caching to avoid re-invoking the C# compiler unless necessary.

See https://github.com/aspnet/DotNetTools/tree/rel/2.0.0-preview2/src/Microsoft.DotNet.Watcher.Tools#msbuild for more details on configuring dotnet-watch in your *.csproj files.

like image 77
natemcmaster Avatar answered Oct 21 '22 08:10

natemcmaster