Develop/debug. NET core code on MAC using visual Studio code

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

Develop/debug. NET core code on MAC using visual Studio code

The. Net Core 1.0 is finally released, and one of the big selling points of the core is cross-platform. This cross-platform is not just a cross-platform operation, but also a cross-platform development. Today it's time to study how to use vs code under Mac to develop. NET core programs and debug the code.

1. Install. NET Core

To open a terminal on a Mac:

~$ Brew Update

~$ Brew Install OpenSSL

~$ Brew Link--force OpenSSL

If you cannot use the Brew command, install homebrew First, and then go to Mac prerequisites.

Download. NET Core sdk:https://go.microsoft.com/fwlink/?linkid=809124

When the download is complete, double-click the PKG installation:

After the next completion, the. Net core is installed on your Mac.

2. Create a new. NET Core Program

Open your Mac's terminal:

mkdir Hwapp

CD Hwapp

dotnet New

These commands are to create a new directory called Hwapp and then initialize a project under that directory, similar to creating a new console project with vs.

3. Run a program

In the terminal, navigate to the Hwapp directory and execute the command:

dotnet Restore

Dotnet Run

These 2 commands are said to restore the dependency of the project, and compile the run, output Hello world.

4. Install Visual Studio Code

There is no universe first IDE on Mac VS then how do we write code? Don't worry, Microsoft has developed an editor VS Code for our cross-platform program for. NET Core. Although the VS code hasn't been released for much longer, the individual feels that it has surpassed the previously used editors on Macs like atom,sublime text. Not only can develop C #, and debugging Nodejs is also very handy.

Download: https://code.visualstudio.com/b?utm_expid=101350005-21.ckupCbvGQMiML5eJsxWmxw.1&utm_referrer=https%3A% 2f%2fwww.microsoft.com%2fnet%2fcore

Open the Hwapp folder with vs code after loading:

5. Install the C # extension for VS code

Open vs Code, press the shortcut key: command+p, enter ext install CSharp in the popup input box, select the first C # in the Search dropdown box, install it.

After installing the C # extension, let's open the Program.cs file and edit it. This time already has C # standard code coloring, with smart hints.

6. Debug Program

Before debugging, we need to configure the Luanch.json file.

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

We mainly need to modify the program property settings, in fact, is the current executable path, note that there is no EXE under the Mac, compiled after the DLL.

"${workspaceroot}/bin/debug/netcoreapp1.0/hwapp.dll"

After the configuration is ready, we can start the formal debugging process.

VS code has a bug-like icon in the left sidebar, click to switch to debug mode, vs code in the next breakpoint in the same as VS, in the left click on the line of code, a red dot appears, indicating the bottom breakpoint success.

Select the. NET Core Launch (console) Console debug mode in the drop-down box next to the green Arrow. Click on the green arrow to start debugging, if there is a breakpoint, the code will stop at the breakpoint location.

Using the same way as vs basic, F5 execution, F10 single step Skip, F11 single-step debugging, mouse hover on the variable can view values, monitoring variables and so on.

Well, using vs code to debug. NET core code is pretty much the same, and you can happily develop. NET programs on your Mac.

Develop/debug. NET core code on MAC using visual Studio code

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.