这时我正在尝试创建一个基于ASP.Net Core(C#)的React Web应用程序.我在TypeScript中编写了代码.我将我的代码与Webpack捆绑在一起.源地图已启用.
现在我想在Visual Studio Code中调试我的(Typescript)代码. Chrome中的调试效果很好.所以源地图都正常工作.
这可能吗?我在使用Node.js服务器时发现了很多东西/教程,但在使用ASP.Net Core时却没有.
谢谢你指出我正确的方向.或者甚至更好,编写一个小教程,我将如何设置我的VSCode(launch.json等)
解决方法
好了又经过3个小时的网络搜索后,跟随GitHub问题我找到了解决方案.
正如@ulubeyn所提到的,你将需要Chrome Link to Debugger for Chrome的扩展调试器
然后你必须在launch.json中添加一个配置.像这样的东西:
{ "name": "Launch Chrome","type": "chrome","request": "launch","url": "http://localhost:5000","webRoot": "${workspaceRoot}/wwwroot" }
从去年11月开始,我们可以在VS Code中启动多个调试器.为此,您必须在launch.json中添加“化合物”(source)部分,其中提到了要一起启动的不同配置名称.
这是我最后的launch.json.请注意,我已在“.NET Core Launch(web)”配置中将“launchBrowser”“enabled”属性设置为false,以防止此配置打开新的浏览器选项卡,因为我们打开了一个附带调试器的新Broser “启动Chrome”配置.
{ "version": "0.2.0","compounds": [ { "name": "ASP.Net Core & Browser","configurations": [".NET Core Launch (web)","Launch Chrome"] } ],"configurations": [ { "name": ".NET Core Attach","type": "coreclr","request": "attach","processId": "${command:pickProcess}" },{ "name": ".NET Core Launch (web)","preLaunchTask": "build","program": "${workspaceRoot}/bin/Debug/netcoreapp1.1/VoteExample.dll","args": [],"cwd": "${workspaceRoot}","stopAtEntry": false,"launchBrowser": { "enabled": false,"args": "${auto-detect-url}","windows": { "command": "cmd.exe","args": "/C start ${auto-detect-url}" },"osx": { "command": "open" },"linux": { "command": "xdg-open" } },"env": { "ASPNETCORE_ENVIRONMENT": "Development" },"sourceFileMap": { "/Views": "${workspaceRoot}/Views" } },{ "name": "Launch Chrome","webRoot": "${workspaceRoot}/wwwroot" } ] }
现在,我们可以在一个Visual Studio代码窗口中调试ASP.NET核心应用程序和客户端代码.不需要“.NET Core Attach”配置部分,但有时我想在正在运行的进程上附加调试器.