Tag: dotnet

  • How to create .NET console program

    How to create .NET console program

    Once you have dotnet SDK installed, you can create your first program.

    To create a console project run

    dotnet new console -o MyApp
    

    create dotnet console project

    This will create MyApp folder with 2 files inside. Program.cs is a basic program that prints “Hello World” text in the console.

    dotnet application directory structure

    To run the dotnet project, you can use the command

    dotnet run
    

    running dotnet application

    Back to dotnet

  • Install .NET SDK on Ubuntu 20.04

    Install .NET SDK on Ubuntu 20.04

    Microsoft .NET SDK and Run time now available for Linux. To install .NET SDK and runtime on Ubuntu 20.04, follow the instructions below

    Run the following commands as user root. If you are logged in as a normal user, use the command “sudo su” to become user root.

    wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
    dpkg -i packages-microsoft-prod.deb
    rm packages-microsoft-prod.deb
    

    Update the repo and install apt-transport-https

    apt-get update
    apt-get install -y apt-transport-https
    

    Search for available dotnet-sdk versions

    apt-cache search dotnet-sdk
    

    apt search dotnet-sdk

    On Ubuntu 20.04, Microsoft provides .NET SDK version 2.1, 3.1, and 5. Let’s install version 5.

    apt-get install -y dotnet-sdk-5.0
    

    To find the version of .NET SDK, run

    dotnet --version
    

    Find  dotnet version in Ubuntu

    You can find .NET SDK and runtime available with commands

    dotnet --list-sdks
    dotnet --list-runtimes