Create an empty directory somewhere ...
mkdir HelloWorld
cd HelloWorld
Then use the built in scaffolding technology to create a Hello World sample
dotnet new console -o
This command creates two files:
HelloWorld.csproj
describes the project dependencies, settings, and Target FrameworkProgram.cs
which defines the source code for the main entry point and the console emitting of "Hello World".If the dotnet new
command fails, make sure you have installed .NET Core properly. Open the Program.cs
file in your favorite editor to inspect it:
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
To restore the project dependencies and the .NET runtime, execute
dotnet restore
To compile the application and execute it, enter
dotnet run
This last command prints "Hello World" to the console.