Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we debug ASP.NET MVC web application in Visual Studio Code?

Microsoft just released Visual Studio Code a couple of days ago.

How can we debug an ASP.NET MVC applications from within that IDE?

like image 768
thangchung Avatar asked May 04 '15 09:05

thangchung


1 Answers

Install the C# Extension

Open vscode and install the C# Extension.

  • CTRL + P
  • ext install csharp
  • Click Install.
  • After install, click Enable and restart vscode.

ext install csharp

Add launch.json and tasks.json

Open your project's directory in vscode. File > Open Folder...

Vscode might ask: Required assets to build and debug are missing from your project. Add them?

Required assets...

If so, choose Yes. This will add a .vscode directory with a launch.json and tasks.json file.

Note: If vscode does not ask this, you must ensure those files have the appropriate settings. One way to do that is to delete the existing .vscode directory and then restart vscode.

Debug

Open the Debug View (CTRL + SHIFT + D), choose a configuration, and click the green arrow. If you aren't sure which configuration to choose, use .NET Core Launch (web).

Debug view...

If you're setup properly, the web browser will open at localhost:5000 and the DEBUG CONSOLE will display output.

launch.json notes

This works for an EXE in net451.

"program": "${workspaceRoot}\\bin\\Debug\\net451\\myApp.exe",

This works for a DLL in netcoreapp1.0.

"program": "${workspaceRoot}\\bin\\Debug\\netcoreapp1.0\\myApp.dll",

program.json notes

Enable portable PDBs by adding the following entry. Otherwise you will receive the "No symbols have been loaded for this document" message.

"buildOptions: {
    "debugType": "portable",
}

See also

  • https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger.md
  • https://code.visualstudio.com/Docs/editor/debugging
  • https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp
like image 105
Shaun Luttin Avatar answered Sep 18 '22 12:09

Shaun Luttin