Use Visual Studio Code to develop/debug. NET Core Code on Mac, and use Visual Core

Source: Internet
Author: User
Tags dotnet install homebrew install openssl

Use Visual Studio Code to develop/debug. NET Core Code on Mac, and use Visual Core

. Net Core 1.0 has finally been released. A major selling point of Core is cross-platform. This cross-platform not only runs across platforms, but also supports cross-platform development. Today, I took the time to study how to use VS Code in Mac to develop. NET Core programs and debug Code.

1. Install. NET Core

Open the terminal on mac:

~ $ Brew update

~ $ Brew install openssl

~ $ Brew link -- force openssl

If you cannot use the brew command, install homebrew first.

Download. NET Core SDK: https://go.microsoft.com/fwlink? LinkID = 809124

After the download is complete, double-click pkg to install:

After the Next step is complete,. Net Core is installed on Mac.

2. Create a. NET Core program

Open the Mac terminal:

Mkdir hwapp

Cd hwapp

Dotnet new

These commands create a directory named hwapp and initialize a project under the directory, similar to creating a console project with.

3. Run a program

Locate the hwapp directory on the terminal and run the following command:

Dotnet restore

Dotnet run

These two commands are used to restore the dependencies of the project, compile and run the commands, and output Hello World.

4. Install Visual Studio Code

There is no cosmic first ide vs on Mac. How can we write code? Don't worry. Microsoft has developed an editor VS Code for the. NET Core cross-platform program. Although VS Code was not released for a long time, I personally think it has surpassed Atom, Sublime Text, and other frequently used editors on Mac. Not only can C # be developed, but Nodejs debugging is also very handy.

Download: https://code.visualstudio.com/B? Utm_expid = 101350005-21.ckuw.vgqmiml5ejsxwmxw.1 & utm_referrer = https % 3A % 2F % 2Fwww.microsoft.com % 2 Fnet % 2 Fcore

After installation, use VS Code to open the hwapp Folder:

5. Install C # extension of VS Code

Open VS Code and press the shortcut key: Command + p. In the displayed input box, enter ext install csharp. In the search box, select the first C # and install it.

After installing the C # extension plug-in, open the Program. cs file and edit it. At this time, C # Standard Code coloring and smart prompts are available.

6. debug the program

Before debugging, We need to configure the luanch. json file.

Luanch. json is a file used to describe the configuration of the Debugger.

We mainly need to modify the setting of the program attribute, which is actually the Path of the current executable file. Note that there is no exe in the Mac, and the dll is compiled.

"$ {WorkspaceRoot}/bin/Debug/netcoreapp1.0/hwapp. dll"

After the configuration, we can start to debug the program.

There is a bug icon in the left sidebar of VS Code. After you click it, switch to the debugging mode. The breakpoint in VS Code is the same as that in VS. Click on the far left of the Code line to see a red dot, indicates that the breakpoint is successfully placed.

In the drop-down box next to the Green Arrow, select the. NET Core Launch (Console) Console debugging mode. Click the Green Arrow to start debugging. If there is a breakpoint, the code will stop at the breakpoint.

The usage is basically the same as VS. F5 is executed, F10 is skipped in one step, F11 is debugged in one step, and you can hover the mouse over the variable to view the value, monitoring variable, and so on.

Well, it's almost time to use VS Code to debug. NET Core Code. You can develop. NET programs happily on Mac.

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.