1. Install .NET and build your first app on Windows

  2. 1

    Install .NET Core SDK

    To start creating .NET apps you just need to download the .NET Core SDK for Windows.

    Download .NET Core SDK

    This installer will install the latest stable version of the tools and put them on your PATH so you can run dotnet from the Console.

    Video: Creating a Simple .NET Application on Windows

  3. 2

    Initialize some code

    dotnet new creates a new application, console is the type of application to create, and -o hwapp sets an output directory of hwapp (short for Hello World app). cd hwapp moves into the newly created app directory.

    1. dotnet new console -o hwapp
    2. cd hwapp

    The template for console applications created a Program.cs file, with code to write "Hello World" to the console.

    Program.cs

    using System;
    
    namespace hwapp
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("Hello World!");
            }
        }
    }
  4. 3

    Run the app

    Finally, dotnet run will run your app.

    1. dotnet run
  5. Success

    You've built and run your first .NET app.

  6. Get an editor

    Visual Studio is a fully-featured integrated development environment (IDE) for developing .NET apps on Windows.

    Download Visual Studio

    Select the .NET Core cross-platform development workload during installation.

  7. Keep learning

    While you wait for Visual Studio to install, try our in-browser tutorial.

    Then, build your first .NET app using Visual Studio.

  1. Install .NET and build your first app on RHEL 7

  2. Red Hat provides full support for .NET Core on RHEL 7. We’re excited to see our partners like Red Hat follow our release so quickly. For more information head to www.RedHatLoves.NET.
  3. 1

    Enable the .NET channel for Red Hat Enterprise Linux 7

    In order to install .NET from Red Hat on RHEL, you first need to enable the .NET channel which is available under your RHEL 7 subscription. You also need to ensure that your system supports enabling software collections via the scl tool.

    1. subscription-manager repos --enable=rhel-7-server-dotnet-rpms # for RHEL 7 Server
    2. subscription-manager repos --enable=rhel-7-workstation-dotnet-rpms # for RHEL 7 Workstation
    3. subscription-manager repos --enable=rhel-7-hpc-node-dotnet-rpms # for RHEL 7 ComputeNode
    4. yum install scl-utils

    For help on registering your machine to get access to the channel see the Chapter 1 of the .NET Core 2.0 Getting Started Guide at Red Hat.

  4. 2

    Install and enable the .NET Core SDK

    Now you can install the .NET Core SDK and then enable the .NET software collection.

    1. yum install rh-dotnet20
    2. scl enable rh-dotnet20 bash

    For additional help and guidance on installing and enabling .NET on RHEL, see the .NET Core Getting Started Guide at Red Hat.

  5. 3

    Initialize some code

    dotnet new creates a new application, console is the type of application to create, and -o hwapp sets an output directory of hwapp (short for Hello World app). cd hwapp moves into the newly created app directory.

    1. dotnet new console -o hwapp
    2. cd hwapp

    The template for console applications created a Program.cs file, with code to write "Hello World" to the console.

    Program.cs

    using System;
    
    namespace hwapp
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("Hello World!");
            }
        }
    }
  6. 4

    Run the app

    Finally, dotnet run will run your app.

    1. dotnet run
  7. Success

    You've built and run your first .NET app.

  8. Get an editor

    Visual Studio Code is a cross platform code editor, with support for .NET.

    Download Visual Studio Code

    You'll also need the C# extension for Visual Studio Code.

    Download the C# Extension

    There are also third party tools for developing .NET apps. JetBrains Rider is a cross-platform .NET IDE built using IntelliJ and ReSharper technology.

  1. Install .NET and build your first app on CentOS or Oracle Linux

  2. 1

    Add the dotnet product feed

    Before installing .NET Core, you need to register the Microsoft Product feed. This only needs to be done once. First, register the Microsoft signature key, then add the Microsoft Product feed.

    1. sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
    2. sudo sh -c 'echo -e "[packages-microsoft-com-prod]\nname=packages-microsoft-com-prod \nbaseurl=https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/dotnetdev.repo'
  3. 2

    Install the .NET Core SDK

    Please remove any previous preview versions of .NET Core from your system before going to the next step.

    The following commands update the list of products available for installation, installs components required by .NET Core, then installs the .NET Core SDK.

    1. sudo yum update
    2. sudo yum install libunwind libicu
    3. sudo yum install dotnet-sdk-2.0.0
  4. 3

    Initialize some code

    dotnet new creates a new application, console is the type of application to create, and -o hwapp sets an output directory of hwapp (short for Hello World app). cd hwapp moves into the newly created app directory.

    1. dotnet new console -o hwapp
    2. cd hwapp

    The template for console applications created a Program.cs file, with code to write "Hello World" to the console.

    Program.cs

    using System;
    
    namespace hwapp
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("Hello World!");
            }
        }
    }
  5. 4

    Run the app

    Finally, dotnet run will run your app.

    1. dotnet run
  6. Success

    You've built and run your first .NET app.

  7. Get an editor

    Visual Studio Code is a cross platform code editor, with support for .NET.

    Download Visual Studio Code

    You'll also need the C# extension for Visual Studio Code.

    Download the C# Extension

    There are also third party tools for developing .NET apps. JetBrains Rider is a cross-platform .NET IDE built using IntelliJ and ReSharper technology.

  1. Install .NET and build your first app on Debian

  2. 1

    Add the dotnet product feed

    Before installing .NET Core, you need to install a few system components and register the Microsoft Product feed. This only needs to be done once.

    Install system components

    1. sudo apt-get update
    2. sudo apt-get install curl libunwind8 gettext apt-transport-https

    Register the trusted Microsoft Product key

    1. curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
    2. sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg

    Register the Microsoft Product feed

    Debian 9 (Stretch)

    1. sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch main" > /etc/apt/sources.list.d/dotnetdev.list'

    Debian 8 (Jessie)

    1. sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-jessie-prod jessie main" > /etc/apt/sources.list.d/dotnetdev.list'
  3. 2

    Install .NET Core SDK

    Please remove any previous preview versions of .NET Core from your system before going to the next step.

    The following commands update the list of products available for installation, then installs the .NET Core SDK.

    1. sudo apt-get update
    2. sudo apt-get install dotnet-sdk-2.0.0
  4. 3

    Initialize some code

    dotnet new creates a new application, console is the type of application to create, and -o hwapp sets an output directory of hwapp (short for Hello World app). cd hwapp moves into the newly created app directory.

    1. dotnet new console -o hwapp
    2. cd hwapp

    The template for console applications created a Program.cs file, with code to write "Hello World" to the console.

    Program.cs

    using System;
    
    namespace hwapp
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("Hello World!");
            }
        }
    }
  5. 4

    Run the app

    Finally, dotnet run will run your app.

    1. dotnet run
  6. Success

    You've built and run your first .NET app.

  7. Get an editor

    Visual Studio Code is a cross platform code editor, with support for .NET.

    Download Visual Studio Code

    You'll also need the C# extension for Visual Studio Code.

    Download the C# Extension

    There are also third party tools for developing .NET apps. JetBrains Rider is a cross-platform .NET IDE built using IntelliJ and ReSharper technology.

  1. Install .NET and build your first app on Fedora

  2. 1

    Add the dotnet product feed

    Before installing .NET Core, you need to register the Microsoft Product feed. This only needs to be done once. First, register the Microsoft signature key, then add the Microsoft Product feed.

    1. sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
    2. sudo sh -c 'echo -e "[packages-microsoft-com-prod]\nname=packages-microsoft-com-prod \nbaseurl=https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/dotnetdev.repo'
  3. 2

    Install the .NET Core SDK

    Please remove any previous preview versions of .NET Core from your system before going to the next step.

    The following commands update the list of products available for installation, installs components required by .NET Core, then installs the .NET Core SDK.

    Fedora 26 or later versions:

    1. sudo dnf update
    2. sudo dnf install libunwind libicu compat-openssl10
    3. sudo dnf install dotnet-sdk-2.0.0

    Other versions:

    1. sudo dnf update
    2. sudo dnf install libunwind libicu
    3. sudo dnf install dotnet-sdk-2.0.0
  4. 3

    Initialize some code

    dotnet new creates a new application, console is the type of application to create, and -o hwapp sets an output directory of hwapp (short for Hello World app). cd hwapp moves into the newly created app directory.

    1. dotnet new console -o hwapp
    2. cd hwapp

    The template for console applications created a Program.cs file, with code to write "Hello World" to the console.

    Program.cs

    using System;
    
    namespace hwapp
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("Hello World!");
            }
        }
    }
  5. 4

    Run the app

    Finally, dotnet run will run your app.

    1. dotnet run
  6. Success

    You've built and run your first .NET app.

  7. Get an editor

    Visual Studio Code is a cross platform code editor, with support for .NET.

    Download Visual Studio Code

    You'll also need the C# extension for Visual Studio Code.

    Download the C# Extension

    There are also third party tools for developing .NET apps. JetBrains Rider is a cross-platform .NET IDE built using IntelliJ and ReSharper technology.

  1. Install .NET and build your first app on SUSE Linux Enterprise Server or openSUSE

  2. 1

    Add the dotnet product feed

    Before installing .NET Core, you need to register the Microsoft Product feed. This only needs to be done once. First, register the Microsoft signature key, then add the Microsoft Product feed.

    1. sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
    2. sudo sh -c 'echo -e "[packages-microsoft-com-prod]\nname=packages-microsoft-com-prod \nbaseurl=https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/zypp/repos.d/dotnetdev.repo'
  3. 2

    Install the .NET Core SDK

    Please remove any previous preview versions of .NET Core from your system before going to the next step.

    The following commands update the list of products available for installation, installs components required by .NET Core, then installs the .NET Core SDK.

    Note: When installing the SDK, SUSE and OpenSUSE may report that nothing provides libcurl. libcurl should already be installed on supported versions of both distros. Run zypper search libcurl to confirm. The error will present 2 'solutions'. Choose 'Solution 2' to continue installing .NET Core.

    1. sudo zypper update
    2. sudo zypper install libunwind libicu
    3. sudo zypper install dotnet-sdk-2.0.0
  4. 3

    Initialize some code

    dotnet new creates a new application, console is the type of application to create, and -o hwapp sets an output directory of hwapp (short for Hello World app). cd hwapp moves into the newly created app directory.

    1. dotnet new console -o hwapp
    2. cd hwapp

    The template for console applications created a Program.cs file, with code to write "Hello World" to the console.

    Program.cs

    using System;
    
    namespace hwapp
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("Hello World!");
            }
        }
    }
  5. 4

    Run the app

    Finally, dotnet run will run your app.

    1. dotnet run
  6. Success

    You've built and run your first .NET app.

  7. Get an editor

    Visual Studio Code is a cross platform code editor, with support for .NET.

    Download Visual Studio Code

    You'll also need the C# extension for Visual Studio Code.

    Download the C# Extension

    There are also third party tools for developing .NET apps. JetBrains Rider is a cross-platform .NET IDE built using IntelliJ and ReSharper technology.

  1. Install .NET and build your first app on Ubuntu or Mint

  2. 1

    Add the dotnet product feed

    Before installing .NET Core, you need to register the Microsoft Product feed. This only needs to be done once. First, register the Microsoft signature key, then add the Microsoft Product feed.

    Video: Creating a Simple .NET Application on Linux Ubuntu

    Register the trusted Microsoft signature key

    1. curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
    2. sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg

    Register the Microsoft Product feed for your distro version

    Ubuntu 17.04

    1. sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-zesty-prod zesty main" > /etc/apt/sources.list.d/dotnetdev.list'

    Ubuntu 16.04 / Linux Mint 18

    1. sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list'

    Ubuntu 14.04 / Linux Mint 17

    1. sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
  3. 2

    Install .NET Core SDK

    Please remove any previous preview versions of .NET Core from your system before going to the next step.

    The following commands update the list of products available for installation, installs components required by .NET Core, then installs the .NET Core SDK.

    1. sudo apt-get update
    2. sudo apt-get install dotnet-sdk-2.0.0
  4. 3

    Initialize some code

    dotnet new creates a new application, console is the type of application to create, and -o hwapp sets an output directory of hwapp (short for Hello World app). cd hwapp moves into the newly created app directory.

    1. dotnet new console -o hwapp
    2. cd hwapp

    The template for console applications created a Program.cs file, with code to write "Hello World" to the console.

    Program.cs

    using System;
    
    namespace hwapp
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("Hello World!");
            }
        }
    }
  5. 4

    Run the app

    Finally, dotnet run will run your app.

    1. dotnet run
  6. Success

    You've built and run your first .NET app.

  7. Get an editor

    Visual Studio Code is a cross platform code editor, with support for .NET.

    Download Visual Studio Code

    You'll also need the C# extension for Visual Studio Code.

    Download the C# Extension

    There are also third party tools for developing .NET apps. JetBrains Rider is a cross-platform .NET IDE built using IntelliJ and ReSharper technology.

  1. Install .NET and build your first app on macOS

  2. 1

    Install .NET Core SDK

    The best way to install .NET on macOS is to download the official installer.

    Download .NET Core SDK

    This installer will install the latest stable version of the tools and put them on your PATH so you can run dotnet from the Console.

    Note: if you have any problems with installation on macOS, please consult our release notes.

    Video: Creating a Simple .NET Application on Mac

  3. 2

    Initialize some code

    dotnet new creates a new application, console is the type of application to create, and -o hwapp sets an output directory of hwapp (short for Hello World app). cd hwapp moves into the newly created app directory.

    1. dotnet new console -o hwapp
    2. cd hwapp

    The template for console applications created a Program.cs file, with code to write "Hello World" to the console.

    Program.cs

    using System;
    
    namespace hwapp
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("Hello World!");
            }
        }
    }
  4. 3

    Run the app

    Finally, dotnet run will run your app.

    1. dotnet run
  5. Success

    You've built and run your first .NET app.

  6. Get an editor

    Visual Studio for Mac is a fully-featured integrated development environment (IDE) for developing .NET apps on macOS.

    Download Visual Studio for Mac

    There are also third party tools for developing .NET apps. JetBrains Rider is a cross-platform .NET IDE built using IntelliJ and ReSharper technology.

  1. Install .NET and build your first app on Docker

  2. 1

    Install Docker

    Before you can try out the .NET Core Docker base images, you should install Docker.

    Refer to the macOS, Windows or Linux getting started instructions for Docker to learn more about installing Docker.

  3. 2

    Run the container using "dotnet" base image

    The following command will get you a running container with the toolchain, straight off of Microsoft's Docker Hub.

    1. docker run -it microsoft/dotnet:latest
  4. 3

    Initialize some code

    dotnet new creates a new application, console is the type of application to create, and -o hwapp sets an output directory of hwapp (short for Hello World app). cd hwapp moves into the newly created app directory.

    1. dotnet new console -o hwapp
    2. cd hwapp

    The template for console applications created a Program.cs file, with code to write "Hello World" to the console.

    Program.cs

    using System;
    
    namespace hwapp
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("Hello World!");
            }
        }
    }
  5. 4

    Run the app

    Finally, dotnet run will run your app.

    1. dotnet run
  6. Success

    You've built and run your first .NET app.

  7. Keep learning

    Learn more about building .NET apps with Docker.