Get Started C# With .NET Core On MacOS Using VS Code

Today I’m gonna bring you a getting started tutorial about C# just (absolutely) for Mac guys. As you already know, now the .NET framework is open source and it is also known as .NET Core. So even your a Linux guy or Mac guy it doesn’t matter, you can now use your favorite language C# anywhere you want. All you need is to follow these guidelines on how to get started !

So what I’m gonna tell you in this blog post ? Well ,I’m gonna go through few steps that you need to follow in order to work with C# and .NET Core on MacOS.

1 – Installing pre-requisites

First of all you need to have MacOS and a Internet Connection 😉

Then go to https://code.visualstudio.com and download the Visual Studio Code !

Wait… so what is Visual Studio Code ? (If you don’t know 😉 ) Visual Studio Code is a lightweight but powerful source code editor which runs on your desktop and is available for Windows, Mac and Linux. It comes with built-in support for JavaScript, TypeScript and Node.js and has a rich ecosystem of extensions for other languages (such as C++, C#, Python, PHP) and runtimes. [Source : VS Code]

Now what ? Now you have to install it and then open it, click and go to extension section in the left side of the Visual Studio Code and you can see C# extension is right at the top of the list and then click Install.

 

Just after installation is done click Enable and restart the Visual Studio before we move to the next step.

 

Now head on to the .NET Core site https://www.microsoft.com/net/core  and then you have to follow the installation steps given in the .NET Core web page ( Same as I have given here).

First thing you have to do is installing the Homebrew from here http://brew.sh/

What is Homebrew ? Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple’s macOS operating system.

In order to install Open SSL you must have installed Homebrew on your MacOS.

To install Homebrew open the Terminal on your Mac and then copy the code line which is in the Homebrew’s web page and then past it to the Terminal and hit enter !

 

Following small screenshot is on my Mac Terminal window…

screen-shot-2016-10-07-at-8-56-06-pm

Then let it install the Homebrew… If you already have Homebrew installed into your Mac make sure you’r Homebrew is up to date by running the command :

brew update

Now Install the Open SSL using brew by running the following command in Terminal:

brew install openssl

Now, copy other two command which are listed in the .NET Core site and run one after the other in Terminal

First one is ,

ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/

And the second one is,

ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/

All right now we just finish installing the pre-requisites lets move to next step.

2 – Install .NET Core SDK

Now you have to download and Install the .NET Core SDK from the .NET Core SDK official installer.

 

3 – Initializing the Code

So now you have to initilize the code in order to start a project. For that create a new folder in anywhere else in your Mac and then open that folder in VS Code as follows.

Open Visual Studio Code > From the left side click and open the explorer window > Then click the “Open Folder Button”.

 

Now open up the VS code integrated terminal by: View > Integrated Terminal

To initialize the .NET project type the following command in the terminal.

bash-3.2$ dotnet new

Then you should get the Program.cs file and project.json file on your project folder.
Not only that you will get a welcome message in the terminal !
Now run the following command to resolve dependencies.

 

bash-3.2$ dotnet restore

 

Now double click on the Program.cs file from the explorer. So you’ll see the Program class which is automatically created for you by .NET Core.
 
Now it run time  🙂 … To run the program give the following command,

 

bash-3.2$ dotnet run

 

Now you can see you’r application is saying Hello World !
 

 

Hurray !!!! Now you’r ready to using C# with your lovely Mac  🙂

 

So I just wanna mention that Visual Studio Code supports lots of IDE features such as IntelliSense, Snippets,CodeLens and Peek Definition so these features make your life more easier.
Finally, we’ll have a take a look at how you can debug your application in VS Code.To do that put a break point on you’r code by clicking the gray space next to the line number that you need to put the break point. So you can see small red dot just next to the line number if you put it correctly.
 

 

Now from the side bar click the little buggy icon and then you’ll see the debug window.

Now click the green play button to run the debugger ! and then you’ll the application is running and the program hit the break point. Also note that the step menu will appears on the top of the VS Code so now you can Step Into (F11) , Step Over (F10), Step Out (Shift+F11), Stop (Shift + F5) and even Continue (F5) the program.Also you can see Locals on left side window underneath the Variables.
 

 

So… That’s it have fun with you lovely Mac and  Awesome VS Code with lovely C#  😛
See you next time !

 

Useful Resources :
About the Author

Dileepa S. Rajapaksa

C# .NET developer, mostly interested in Microsoft Technologies, Trainee Software Developer at Microsoft Sri Lanka and Undergraduate Student at Sri Lanka Institute of Information Technology.

Developing Windows Phone & Windows 8 apps, Have a skills of programming in C#, C, C++, Java, Python, and PHP. Good experience in Web designing & Development. Creative and innovative User interfaces and User experience designing Creative and self- motivated.

Interested in Photography, Astronomy,Sky Gazing and learn new technologies.

What bots are and aren’t?

In this article I am going to discuss what bots are and what bots aren’t to help set the stage for all of the technical content that I am going to get in to in later articles. Let’s begin with what bots are not. I think the biggest misconception people have about bots is that they are necessarily have to be artificial intelligence. Bots don’t necessarily have to be artificial intelligence. They can be very simple automation utilities like resetting a password. So you might have an IT help desk bot that you send a message on Skype to say hey, I want to reset my password. And that bot can run through some series of predefined tasks and do that. And in this case that bot isn’t learning based on the conversation, it is not intelligent. But it is very simple and useful because it is communicating on a channel where you would not otherwise have been able to follow this task. So again it does not have to be artificial intelligence. It really can just be a way of interacting with the user. Rather than necessarily having them. To install an app on a phone, they can just talk to the bot instead and perform whatever those tasks are.

Bots are also not necessarily just text interfaces. You can use images, buttons, carousels, audios and lot of rich controllers to increase the user friendliness of your bot. In “Puwath Bot” when you type help, you will get a carousel with images and buttons. So you can interact with buttons.

Bots also aren’t necessarily just natural language processing. But if you are going to use text you don’t necessarily have to be doing some parsing where you are finding entities and intents. And you can build some very powerful bots around natural language processing. But bots can also just use things like regular expressions. So here I have got an example. Using “Weather Bot” you can get latest weather reports and forecasts by entering your nearest city or zip code. I am just communicating with this bot with regular expressions. So it’s really more of a command line application, there’s no necessary natural language processing here. There are plenty of applications where you would not require Language processing.

Let’s talk focus on what bots are. Simply bots are just apps with a new interface. So things you can do in a regular application. You can do in a bot too. You also can have a back end which will keep the business logic that follows some series of steps. But really the difference here is the user interface. You might be communicating over text, Skype, Slack, Facebook or other channels. And behind the scene you have really just got an app. So if bots are just apps, Why we are using bots instead of apps? There are few reasons for that. One of them is definitely you have faster access. You are already talking on these channels all the time. Instead of having to download an application to get something done, You can get it done being inside Skype, Facebook or any other channels. Take “Puwath Bot”, Without downloading a separate application, You can read latest news being inside Facebook, Skype or any other channel. One of the other reason is that it is available across more platforms. Again, these bots are sitting on channels that you always have access to. Same experience on Android, iOS, Windows operating systems. User experience does not depend on the platform.

Let’s say that I own a textile shop. I put together my Facebook page, and somebody then discovers it. That visitor might be a potential customer. It would be nice to be able to allow them to take the next step, actually allowing them to  buy something. They see my Facebook page, they can click on message. They can say, I need to buy a trouser. Then bot will show suggestions and customer can proceed with the checkout. I am not sending them out of Facebook or to a different web page and I am allowing them to do that right where they happen to be.

Bots also have less friction to build and deploy. The developer does not have to code an iOS application or an Android application, or worry about how applications are going to look on different platforms. Instead of that he can build and deploy the bot. Then using bot connector, he can connect the bot with different channels without having to worry about any customization across those channels. It is definitely a lot less friction and the cost is also less when comparing with a regular application. If you have an application where your functionality more relates to a natural interaction and to a conversation, then a bot is suitable than an app.

When designing an UI of a regular application, You really need to understand it is that your users are most likely going to use. Then you will put those foremost in front of the user. And then anything else that’s secondary. Actually this totally depends on the user. Most of your users might feel comfortable by arranging the UI like that. But what about others? By having a bot you allow them to type what they want and get straight to that particular feature without having to open several pages like in a regular application.

You can use cloud services to power up your bots. With Azure we have got services like Machine Learning and Azure search. These things are not built into the bot framework but you can use them in your bots to build an incredible bot experience.