Workshop Wednesday – .NET Core

Standard

To get started you’ll need to download and install .NET Core you can start by visiting dot.net

ww-dnc-1

Once on the .NET website select the Downloads or select the large “Download” button

ww-dnc-2

Once on the .NET Downloads page select “.NET Core”

ww-dnc-3

Once that has been selected choose “Runtime” from the All Downloads and choose the current  .NET Core runtime from the list for your platform such as Windows, macOS or Linux

ww-dnc-4

Once the Runtime has been downloaded then you need to Save As and Run or Save to a location on your computer and select the installer from that location. The you need to run the installer.
ww-dnc-5

Once you’ve read and agreed to the license terms and conditions and selected Install the installation should then proceed until it is completed.

ww-dnc-6

Once the installation has completed go to your system’s command prompt, console or similar and then create a new directory by using something like this which is from Windows:

mkdir dotnetcore

ww-dnc-8

Then once the directory has been created you need to type in the following:

dotnet new console

Once done then press enter, the first time you do this it will Decompress and Configure that version of .NET Core for use on your computer, subsequent uses of this command will be quicker.

ww-dnc-9

Once the new process has completed then you need to type in the following:

dotnet restore

Then you press enter, and it will restore any dependencies the project will have, for the moment this won’t be very many but with more complex and bigger examples you’ll have a few libraries you can use in your program and can use this process to install and update them.

ww-dnc-10

Once the “NuGet” packages have been restored then you can then run the application by typing in the following command:

dotnet run

Once you’ve pressed enter the program will run and output:

Hello World!

Within the folder for the project there will be a Program.cs file which you can open with your favourite text editor and it will contain the following code:

using System;

namespace dotnetcore
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

You can then use this example as a basis for your own console programs and applications, for example if you change the “Console.WriteLine” part to as follows:

Console.WriteLine("Hello .NET Core!");

Then you can use the command:

dotnet run

Followed by enter to run your program with that change and see the new output.

ww-dnc-11There’s plenty more you can do in a .NET Core Console application, that’s just the start but hopefully enough to get started with!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s