Get started with VS Code using C# and .NET Core on a Mac

Sign in to queue

Description

This is a quick tutorial for getting started with C# in VS Code on a Mac with .NET Core!

 

--------

Transcript

Hi, this is a video tutorial to get

started with Visual Studio code

on your Mac with .NET Core, wait,

something doesn't feel right.

Much better.

First, go to your favorite search

engine and type in Visual Studio

code, one of the first results

will be code.visualstudio.com, and

it'll bring you automatically

to the Mac download.

And this installs really quickly,

because Visual Studio code is

a lightweight source code editor,

it's much different from Visual

Studio, which is the fully featured,

integrated development environment,

but with .NET Core and

the C Sharp extension,

VS code can do some really cool

debugging stuff with C Sharp.

All you need to do is go over to

the Extensions tab on the left,

click it and

install the C Sharp extension,

it'll be one of

the first suggestions.

Now that you have Visual Studio

code, you need .NET Core to compile

your C Sharp, so go back to your

browser and type in .NET Core,

one of the first results will

be Microsoft.com/net/core.

To install it on a Mac, the easiest

way is by using HomeBrew,

if you don't have it installed,

it's very easy to get, just copy and

paste the HomeBrew install command

from their main website into your

terminal.

And I'm going to be speeding

up these installs slightly,

because I wanna give a tour,

and not waste anyone's time.

Now I can run brew update and

brew install openssl,

because we'll also need openssl, and

I'll run the next few commands here,

which make a directory and

make your symbolic links.

Next click Download .NET Core SDK,

go ahead and

click on that download and click

through the .NET Core installer.

Once the install is complete, I'll

take you through the next commands

on our install page, which create

a basic .NET Core console app,

I'll speed this up a little bit.

There we go, so I'll navigate to my

Documents folder at the terminal.

And type dotnet new console -o

hwapp to initialize my project.

Here I'm using the -o to specify

the output directory as hwapp,

the hw standing for hello, world.

Now I can use the .NET commands

to run .NET restore and

.NET run from the command line,

.NET restore restores my project

dependencies using NuGet.

Now let's open Visual Studio codes

so we can edit and debug our

C Sharp, go to the file tab on

the left and click Open Folder,

I'll open the hwapp folder that I

just created from the command line.

As you can see, I have a csproj

loaded here next to my program .CS

file, pop ups will appear asking you

to yes load the build assets and

restore your project.

Now, let's debug our app,

click on the Debug tab on the left,

it's the one with a little bug

with a line crossing it out.

Now, you can hit the green debug

arrow at the top left of the Debug

tab, you can also drop a break point

and hit Debug again, and you can see

the local variables loaded on

the left, you can also check those

variables in the Debug console by

typing them, and there's args.

Now I'll hit continue

to complete debugging,

so that's your first .NET

Core app running on your Mac.

Thanks for watching.

Embed

Download

The Discussion

  • User profile image
    terrajobst

    Great video but the papers are highly distracting. Get your office in order! ;)

  • User profile image
    kendrahavens

    You had one job, Immo. :P

  • User profile image
    agustinistmo

    Problem:  

    -bash: dotnet: command not found

    Solution:

    PATH=/usr/local/share/dotnet/:$PATH

    Tanks adelynx

    https://github.com/dotnet/cli/issues/2005

  • User profile image
    tanyuj

    @agustinistmo Thanks for your solution!

  • User profile image
    Megan Johnson

    I need some help with this i don't know what to do with this

  • User profile image
    Derek

    I'm experiencing issue with dotnet build in vscode on a mac via launch.json. The build actually is configure to output a file as well (comments in .xml) via csproj. During the build via vscode terminal it complains about not having the correct permissions. The only way I can get it to work is via sudo dotnet build. Is there a way to configure vscode to launch the app (build then launch) with admin rights? Or do you have to just open the app always with elevated permissions?

Add Your 2 Cents