我们如何在Visual Studio Code中调试ASP.NET MVC Web应用程序?

时间:2022-09-01 23:42:34

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

微软几天前刚刚发布了Visual Studio Code。

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

我们如何从该IDE中调试ASP.NET MVC应用程序?

3 个解决方案

#1


You can't (in this preview release). See: https://code.visualstudio.com/Docs/aspnet5

你不能(在这个预览版中)。请参阅:https://code.visualstudio.com/Docs/aspnet5

#2


Install the C# Extension

Open vscode and install the C# Extension.

打开vscode并安装C#Extension。

  • CTRL + P
  • CTRL + P.

  • ext install csharp
  • ext安装csharp

  • Click Install.
  • After install, click Enable and restart vscode.
  • 安装后,单击“启用”并重新启动vscode。

我们如何在Visual Studio Code中调试ASP.NET MVC Web应用程序?

Add launch.json and tasks.json

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

在vscode中打开项目的目录。文件>打开文件夹...

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

Vscode可能会问:项目中缺少构建和调试所需的资产。加他们?

我们如何在Visual Studio Code中调试ASP.NET MVC Web应用程序?

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

如果是,请选择是。这将添加一个带有launch.json和tasks.json文件的.vscode目录。

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.

注意:如果vscode不询问此问题,则必须确保这些文件具有适当的设置。一种方法是删除现有的.vscode目录,然后重新启动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).

打开调试视图(CTRL + SHIFT + D),选择配置,然后单击绿色箭头。如果您不确定选择哪种配置,请使用.NET Core Launch(Web)。

我们如何在Visual Studio Code中调试ASP.NET MVC Web应用程序?

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

如果设置正确,Web浏览器将在localhost:5000打开,DEBUG CONSOLE将显示输出。

launch.json notes

This works for an EXE in net451.

这适用于net451中的EXE。

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

This works for a DLL in netcoreapp1.0.

这适用于netcoreapp1.0中的DLL。

"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.

通过添加以下条目启用便携式PDB。否则,您将收到“此文档未加载符号”消息。

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

See also

#3


If you are using windows environment then you have to configure actions and add breakpoints, similar to visual studio and then use F5. See following image,

如果您使用的是Windows环境,则必须配置操作并添加断点,类似于visual studio,然后使用F5。见下图,

我们如何在Visual Studio Code中调试ASP.NET MVC Web应用程序?

More info here

更多信息在这里

#1


You can't (in this preview release). See: https://code.visualstudio.com/Docs/aspnet5

你不能(在这个预览版中)。请参阅:https://code.visualstudio.com/Docs/aspnet5

#2


Install the C# Extension

Open vscode and install the C# Extension.

打开vscode并安装C#Extension。

  • CTRL + P
  • CTRL + P.

  • ext install csharp
  • ext安装csharp

  • Click Install.
  • After install, click Enable and restart vscode.
  • 安装后,单击“启用”并重新启动vscode。

我们如何在Visual Studio Code中调试ASP.NET MVC Web应用程序?

Add launch.json and tasks.json

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

在vscode中打开项目的目录。文件>打开文件夹...

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

Vscode可能会问:项目中缺少构建和调试所需的资产。加他们?

我们如何在Visual Studio Code中调试ASP.NET MVC Web应用程序?

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

如果是,请选择是。这将添加一个带有launch.json和tasks.json文件的.vscode目录。

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.

注意:如果vscode不询问此问题,则必须确保这些文件具有适当的设置。一种方法是删除现有的.vscode目录,然后重新启动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).

打开调试视图(CTRL + SHIFT + D),选择配置,然后单击绿色箭头。如果您不确定选择哪种配置,请使用.NET Core Launch(Web)。

我们如何在Visual Studio Code中调试ASP.NET MVC Web应用程序?

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

如果设置正确,Web浏览器将在localhost:5000打开,DEBUG CONSOLE将显示输出。

launch.json notes

This works for an EXE in net451.

这适用于net451中的EXE。

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

This works for a DLL in netcoreapp1.0.

这适用于netcoreapp1.0中的DLL。

"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.

通过添加以下条目启用便携式PDB。否则,您将收到“此文档未加载符号”消息。

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

See also

#3


If you are using windows environment then you have to configure actions and add breakpoints, similar to visual studio and then use F5. See following image,

如果您使用的是Windows环境,则必须配置操作并添加断点,类似于visual studio,然后使用F5。见下图,

我们如何在Visual Studio Code中调试ASP.NET MVC Web应用程序?

More info here

更多信息在这里