我的角度应用程序在调试时没有命中断点? [英] My Angular application doesn't hit breakpoint when debugging?
问题描述
Kinda使用C#Web API后端的Visual Studio代码和角度应用程序。在C#中命中断点没有问题,只是在VS代码中不会在角度应用程序中命中它!
我可以通过dotnet run
和ng serve
在终端的浏览器中很好地运行这两个应用程序,但是当我点击调试按钮调试我的应用程序时,角度断点从红色变为空心灰色!
免责声明-我必须指出,我更改了很多文件名并重命名了.csproj文件,因为我希望应用程序反映我的名字,而不是教师使用的名字。在执行此操作之前,我可以在角度应用程序中设置断点并点击它们。
以下是我尝试过的内容。
- 重新启动VS代码
- NG开始,NG发球
- 在包含我的两个项目文件夹(Ng、.Net)的同一文件夹级别生成了新的启动.json文件(由VS代码自动生成)
- 已删除我的工作区文件(似乎无法生成新文件,不确定是否需要)
在文件中:
error.interceptor.ts
我正在尝试通过以下方式测试此异常处理:
throw new Exception("Some login error");
在我的登录方法中。
我可以设置如下所示的断点,但它会变成一个灰色圆圈,并且在单击"调试"时永远不会命中。
这里是我设置断点的位置
这是我在运行调试器时看到的,红色圆圈变成灰色和中空。我希望在调试时能够单步执行此错误侦听器,可以吗?
然后在我的角度应用程序登录方法中,我的断点变成灰色
这是我的启动.json文件
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/Yogabandy.API/bin/Debug/netcoreapp2.2/Yogabandy.API.dll",
"args": [],
"cwd": "${workspaceFolder}/Yogabandy.API",
"stopAtEntry": false,
"launchBrowser": {
"enabled": true
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
已加载的‘/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.2.4/System.Threading.dll’.该模块是在没有符号的情况下建造的。 加载的‘/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.2.4/System.IO.FileSystem.Watcher.dll’.已跳过加载符号。模块已优化,并且启用了调试器选项"仅我的代码"。
推荐答案
事情是这样的!它与.vscode文件中的项目路径以及一次调试两个单独的项目文件夹的需要有关!
${workspaceFolder}
我的应用程序有两个文件夹
- 瑜伽班迪-SPA(角度APP)
- Yogbany.API(ASP.NET核心Web API)
我认为.vscode文件的最佳位置在根级别,除非有人有更好的解决方案,否则这似乎是最佳位置。
但问题是需要更正工作区文件夹的路径。
更正的路径
"webRoot": "${workspaceFolder}" // old
"webRoot": "${workspaceFolder}/Yogabandy-SPA" // new
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/Yogabandy.API.dll" // old
"program": "${workspaceFolder}/Yogabandy.API/bin/Debug/netcoreapp2.2/Yogabandy.API.dll" // new
// removed from the 'server' command so two debuggers don't open, just one
"serverReadyAction": {
"action": "openExternally",
"pattern": "^\s*Now listening on:\s+(https?://\S+)"
},
添加了一个复合,以便我可以同时调试这两个项目。
"compounds": [{
"name": "Server/Client",
"configurations": ["server", "client"]
}]
启动调试器时仍有一个小问题。VS代码在下面显示了这一点,但我现在可以一起调试这两个应用程序,并命中两个项目的所有断点。
如果有人有更好的解决方案,请告诉我。
"compounds": [{
"name": "Server/Client",
"configurations": ["server", "client"]
}],
"configurations": [{
"name": "server",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/Yogabandy.API/bin/Debug/netcoreapp2.2/Yogabandy.API.dll",
"args": [],
"cwd": "${workspaceFolder}/Yogabandy.API",
"stopAtEntry": false,
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"type": "chrome",
"request": "launch",
"name": "client",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}/Yogabandy-SPA"
}
这篇关于我的角度应用程序在调试时没有命中断点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!