[英]How can we debug ASP.NET MVC web application in Visual Studio Code?
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 应用程序?
Open vscode and install the C# Extension.打开 vscode 并安装 C# 扩展。
ext install csharp
Open your project's directory in vscode.在 vscode 中打开你的项目目录。 File > Open Folder...
文件 > 打开文件夹...
Vscode might ask: Required assets to build and debug are missing from your project. Vscode 可能会问:您的项目中缺少构建和调试所需的资产。 Add them?
添加它们?
If so, choose Yes .如果是,请选择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.注意:如果 vscode 没有询问这个,你必须确保这些文件有适当的设置。 One way to do that is to delete the existing
.vscode
directory and then restart vscode.一种方法是删除现有的
.vscode
目录,然后重新启动 vscode。
Open the Debug View ( CTRL + SHIFT + D ), choose a configuration, and click the green arrow.打开调试视图 ( CTRL + SHIFT + D ),选择一个配置,然后单击绿色箭头。 If you aren't sure which configuration to choose, use .NET Core Launch (web).
如果您不确定要选择哪种配置,请使用 .NET Core Launch (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 将显示输出。
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",
Enable portable PDBs by adding the following entry.通过添加以下条目启用可移植 PDB。 Otherwise you will receive the "No symbols have been loaded for this document" message.
否则,您将收到“没有为此文档加载符号”消息。
"buildOptions: {
"debugType": "portable",
}
You can't (in this preview release).您不能(在此预览版本中)。 See: https://code.visualstudio.com/Docs/aspnet5
请参阅: https : //code.visualstudio.com/Docs/aspnet5
Just saw the "Required assets to build and debug are missing from [project name]. Add them?"刚刚看到“[项目名称] 中缺少构建和调试所需的资产。添加它们?” in Visual Studio Code
在 Visual Studio 代码中
There should be a choice to display the "assets" it is talking about adding.应该可以选择显示它正在谈论添加的“资产”。 These "assets" were added previously (yesterday when I created the project) and are only not showing up now because I've restarted my computer.
这些“资产”是之前添加的(昨天我创建项目时),现在没有显示,因为我已经重新启动了我的计算机。 It's a bit confusing.
这有点令人困惑。
If you click the gear icon on the right side,and then select the menu item (Manage Extension) that appears, then you'll see the asset it is talking about:如果您单击右侧的齿轮图标,然后选择出现的菜单项(管理扩展),您将看到它正在谈论的资产:
Here's the info on current version of Visual Studio Code and dependencies...这是有关当前版本的 Visual Studio Code 和依赖项的信息...
Visual Studio Code Version: 1.44.2 Visual Studio 代码版本:1.44.2
Commit: ff915844119ce9485abfe8aa9076ec76b5300ddd提交:ff915844119ce9485abfe8aa9076ec76b5300ddd
Date: 2020-04-16T17:50:03.709Z日期:2020-04-16T17:50:03.709Z
Electron: 7.1.11电子:7.1.11
Chrome: 78.0.3904.130 Node.js: 12.8.1铬:78.0.3904.130 Node.js:12.8.1
V8: 7.8.279.23-electron.0 V8:7.8.279.23-electron.0
OS: Linux x64 5.3.0-51-generic操作系统:Linux x64 5.3.0-51-generic
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.