How to Debug. NET Core RC2 Apps with Visual Studio Code on Windows?

Source: Internet
Author: User

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, followed the Getting Started tutorial and you got your "Hello world!" printed on You R command prompt just by using the CLI. Then you went the next step and your tried to use Visual Studio Code and the C # extension to edit the application outside O F Visual Studio. And finally you want to try and debug and set a breakpoint inside the application, but you encountered some problems and N Othing worked. Here's how to do it work.

Specify the launch configuration

Visual Studio Code needs to know-launch your application, and this is specified in Alaunch.json file inside the. vs Code folder. From the Debug window, click the "Gear" icon and Code would create it for you:just choose the right environment ". NET Core ”.

Then you must specify the "path to your executable. In the 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 has 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 was because for launching, VS Code have to build the project, and this is the done via a task. But no worries, just click the ' Configure Task Runner ' button in the info box, choose which Task Runner your want to use, I n this case ". NET Core", and the Tasks.json file is created for you. More info on Task runners in VS Code can is 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 do you set it, doesn ' t it? Well ... if you were on MAC or Linux it does. But it doesn ' t stop if is on Windows and the Debug Console says something like:

   1:for ' Hwapp.dll '.
   2: ' ... \hwapp\bin\debug\netcoreapp1.0\hwapp.pdb ' is a Windows pdb.
   3: These is not supported by the Cross-platform. NET Core Debugger.

Introducing Portable PDBs

In order to being able to debug cross-platform,. NET core have now a "portable PDB" format, and the newly introduced. NET Core Debugger for Visual Studio Code is supports this format. Unfortunately by default in Windows, the. NET Core build generates standard "Windows PDBs", which is not supported. But the fix was easy and you just has to tell the compiler to generate portable PDBs.

This was done by specifying the Debugtype to be portable.

   1: {
   2:   "Buildoptions": {
   3:     "Debugtype" "Portable"
   4:   },
   5:...   
   6: }

and voila! Breakpoints is hit!

How to Debug. NET Core RC2 Apps with Visual Studio Code on Windows?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.