DEV Community

Cover image for Setting Up .NET on macOS: A Step-by-Step Guide

Posted on

Setting Up .NET on macOS: A Step-by-Step Guide

Microsoft's .NET platform is a versatile and powerful framework for developing a wide range of applications, from web and mobile to desktop and cloud-based solutions. If you're a macOS user and want to start working with .NET, you're in the right place. In this guide, we'll walk you through the steps to set up .NET on your macOS.


Before you begin, ensure that your macOS version meets the system requirements for .NET. You'll also need an internet connection to download the necessary components.

Step 1: Install Homebrew

Homebrew is a popular package manager for macOS that simplifies the installation of various software packages, including .NET. If you don't have Homebrew installed, follow these steps to get it:

  1. Open Terminal, which you can find in the “Utilities” folder within the “Applications” directory.

  2. Install Homebrew by running the following command:

   /bin/bash -c "$(curl -fsSL"
Enter fullscreen mode Exit fullscreen mode
  1. Follow the on-screen instructions to complete the Homebrew installation.

Step 2: Install .NET SDK

The .NET Software Development Kit (SDK) contains everything you need to build and run .NET applications. With Homebrew installed, you can easily install the .NET SDK:

  1. In Terminal, run the following command to install the .NET SDK:

    brew install --cask dotnet-sdk
  2. Homebrew will download and install the .NET SDK for you. This might take a few minutes, depending on your internet speed.

Step 3: Verify Installation

After the installation is complete, you can verify that .NET is installed correctly by running the following command in Terminal:

dotnet --version
Enter fullscreen mode Exit fullscreen mode

This command should display the version of the .NET SDK that was installed.

Step 4: Optional – Install Visual Studio Code

While you can use any text editor or integrated development environment (IDE) for .NET development, Visual Studio Code (VS Code) is a popular choice due to its excellent support for .NET development. You can install it from the macOS App Store or by downloading it from the official website.

Step 5: Create a New .NET Project

Now that you have .NET installed on your macOS, you can create and run your first .NET application. Follow these steps to create a simple “Hello World” application:

  1. Open Terminal and navigate to the directory where you want to create your project.

  2. Create a new directory for your project and navigate into it. For example:

    mkdir MyDotNetApp
    cd MyDotNetApp
  3. Use the following commands to create a new console application, build it, and run it:

    dotnet new console
    dotnet run
  4. You should see “Hello World!” printed on the terminal, indicating that your .NET application is working correctly.

Congratulations! You've successfully set up .NET on your macOS machine and created your first .NET application.

Now you're ready to explore the world of .NET development on macOS. You can use Visual Studio Code or your preferred code editor to build various types of applications, including web applications using ASP.NET, cross-platform desktop applications using .NET MAUI or Xamarin, and more. The .NET ecosystem offers a wide range of tools and libraries to help you develop powerful and feature-rich applications. Happy coding!

Top comments (0)