Developing C# Applications on Mac OS using VS Code
As we know we cannot run Visual Studio directly on Mac OS. So in order to develop applications targeting Microsoft .net framework, we need to rely on other tools including OmniSharp. Now we can also use Visual Studio Code to develop C# based applications.
Let’s first install Visual Studio Code. We can directly download OS compatible VS Code from the following link:
VSCode implements extensions based model. There are a number of extension available to develop applications targeting different platforms. Similarly, there is an extension available for C# development. The extension is provided by Microsoft.
We can directly install the above extension from Visual Studio. Press Command + P and select option from the drop down. The extension provides support for syntax highlight for C# statements.
In order to support complete debugging experience we need to install .net CLI tools. As soon as we install the above extension, it prompts for installation of .net CLI tool to support debugging.
We can download .net CLI tools directly but there is a pre-requisite installation of open ssl using home brew package manager. If home brew is not installed on your machine, it can be downloaded directly using Terminal.
But before installing the CLI tools, we need to first add support for secure connection by installing open ssl. Let’s run the following commands in the terminal window.
Now you can download .net cli tools directly using the following link:
https://go.microsoft.com/fwlink/?LinkID=798400
As soon as it is downloaded, you can run the installation wizard. It is a step-by-step guide to installation. Please remember that you need to have admin rights for this installation. If installation is successful, you should see the following:
The wizard also copies the tools in your PATH so you can run them directly through terminal. Here we have created a sample employeeApp using [dotnet new] command.
Here are the contents of the folder. It has a simple project.json file and Program.cs.
Yes, there is no csproj file for .net core based applications. This might change though as this is still Release Candidate. Here are the contents of project.json.
We can run it directly from the console using dotnet run command. This should compile and run the application.