How to debug .NET Core RC2 app with Visual Studio Code on Windows?
Simone Chiaretta (http://codeclimber.net.nz/archive/2016/05/20/How-to-debug-NET-Core-RC2-app-with-Visual-Studio.aspx)
So, you installed .NET Core RC2 , you followed the getting started tutorial and you got your “Hello World!” printed on your command prompt just by using the CLI. Then you went the next step and you tried to use Visual Studio Code and the C# extension to edit the application outside of Visual Studio. And finally you want to try and debug and set a breakpoint inside the application, but you encountered some problems and nothing worked. Here is how to make it work.
Specify the launch configuration
Visual Studio Code needs to know how to launch your application, and this is specified in alaunch.json file inside the .vscode folder. From the debug window, click the “gear” icon and Code will create it for you: just choose the right environment “.NET Core”.
Then you must specify the path to your executable in the program property. In the standard hwapp sample app, replace
1: "program": "${workspaceRoot}/bin/Debug/<target-framework>/<project-name.dll>",
with
1: "program": "${workspaceRoot}/bin/Debug/netcoreapp1.0/hwapp.dll",
There is much more you can specify in the launch.json file. To see all the options have a look at the official doc: Debugging in Visual Studio Code.
Specify the task runner
If you try to debug now you’ll have another warning: “No task runner configured”.This is because for launching, VS Code has to build the project, and this is done via a task. But no worries, just click the “Configure Task Runner” button in the info box, choose which task runner you want to use, in this case “.NET Core”, and the tasks.json file will be created for you. More info on task runners in VS Code can be found on the offical documentation: Tasks in Visual Studio Code.
Running and debugging
Now you can click the “Start Debugging” button or F5 and the application runs. Cool… Now you set a breakpoint and the executions stops where you set it, doesn’t it? Well… if you are on Mac or Linux it does. But it doesn’t stop if you are on Windows and the Debug Console says something like:
1: WARNING: Could not load symbols for 'hwapp.dll'.
2: '...hwappbinDebugnetcoreapp1.0hwapp.pdb' is a Windows PDB.
3: These are not supported by the cross-platform .NET Core debugger.
Introducing Portable PDBs
In order to be able to debug cross-platform, .NET Core has now a “portable PDB” format, and the newly introduced .NET Core debugger for Visual Studio Code only supports this format. Unfortunately by default, on Windows, the .NET Core build generates standard “Windows PDBs”, which are not supported. But the fix is easy, you just have to tell the compiler to generate portable PDBs.
This is done by specifying the debugType to be portable.
1: {
2: "buildOptions": {
3: "debugType": "portable"
4: },
5: ...
6: }
And voila! Breakpoints are hit!
- Golang语言--【社区推荐阅读】 fmt用法
- 一个SQL性能问题的优化探索(一)(r11笔记第33天)
- HDUOJ-----1074 Integer Inquiry
- PXE无人值守安装Linux
- HDUOJ-----Robot Motion
- 对康托展开的一些心得...
- MySQL 5.7 General Tablespace学习(r11笔记第34天)
- Veeam Backup & Replication(一):安装及配置
- HDUOJ-----Computer Transformation
- Veeam Backup & Replication(二):添加虚拟化主机和配置备份存储
- HDUOJ 2672---god is a girl 《斐波那契数》
- Golang语言--一些基础用法
- 复杂SQL性能优化的剖析(一)(r11笔记第36天)
- hduoj1073--Online Judge
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- sqli-labs练习(第三、四关)
- 使用 Python 操作 word文档
- sqli-labs练习(第五、六关)
- 分享一个Qt写的SMTP邮件客户端(库)
- mysql学习笔记
- MapReduce的常见输入格式之NlineInputFormat
- MapReduce的常见输入格式之KeyValueTextInputFormat
- MapReduce之 FileInputFormat的切片策略(默认)
- MapReduce之片和块的关系
- MapReduce的常见输入格式之CombineTextInputFormat
- MapReduce之Job提交流程
- MapReduce之自定义InputFormat
- MapReduce之MapTask工作机制
- 数据链路层的三个基本问题
- DEBUG ArrayList