In .NET Core we have the option to build applications using command line tool called dotnet command.Though we can use visual studio directly but dotnet CLI command tool is quite useful.
Building a Console App
The dotnet command-line tool can be used for creating different types of applications.It has one option that allows to create a simple console application.
To see all the templates you can use “dotnet new” without any parameters.
Create a new console application from CLI dotnet command
Following will create a console application in the current directory.Note as that this will create project files in the current directory so change to the directory where you want to create the project.
go to windows command prompt.execute the following command:
This will create the required dependencies such as downloading the required nugets. After the above command executes required folders and files are created in the specified folder:
Target framework version
You can check the target framework version of the newly created application by looking at the TargetFramework element of the .csproj file.
Program.cs
This is the main file where program execution starts in .NET Core application.Following is the Program.cs created automatically by the CLI:
using System; namespace sample_apps { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); } } }
Running the console application
You can run the above console application using the following command:
dotnet run
If you open the above application in Visual Studio you can see SDK node under dependencies .SDK stands for .NET Core Software Development Kit and consists of libraries and tools required for developing .NET Core application.