Getting Started with .NET Core: A Practical Beginner's Guide

Set up the .NET SDK, create your first console app and web API, and learn the essentials of the CLI, testing, configuration, and dependency injection.

By Santhor Team

What is .NET Core?

.NET Core, now simply known as .NET, is an open-source, cross-platform framework for building console apps, web APIs, services, and more. You can develop on Windows, macOS, and Linux and deploy virtually anywhere.

Install the tools

  1. Install the .NET SDK from the official download page.
  2. Choose an editor: Visual Studio Code (with the C# extension), Visual Studio, or Rider.
  3. Open a terminal and run dotnet --version to confirm the installation.

Create your first app

  1. Create a folder: mkdir HelloNetCore then cd HelloNetCore.
  2. Generate a console project: dotnet new console -n HelloApp.
  3. Run it: cd HelloApp then dotnet run.

Understand the project

  • HelloApp.csproj: SDK-style project file listing the target framework (for example, net8.0) and package references.
  • Program.cs: the entry point that uses top-level statements.
  • Dependencies: retrieved from NuGet during restore.

Build, restore, and run

  • dotnet restore: downloads NuGet packages.
  • dotnet build: compiles to bin/Debug (or bin/Release).
  • dotnet run: restores, builds, and executes the app.

Add a simple feature

Edit Program.cs to read user input and print a greeting. Try adding a JSON dependency with dotnet add package System.Text.Json, then use it to serialize a simple object. Re-run the app to see the change.

Testing

  1. Create a test project: dotnet new xunit -n HelloApp.Tests.
  2. Create a solution and add projects: dotnet new sln, dotnet sln add HelloApp HelloApp.Tests.
  3. Reference the app from tests: dotnet add HelloApp.Tests reference HelloApp.
  4. Run tests: dotnet test.

Build a web API (optional)

  1. Create an API project: dotnet new webapi -n TodoApi.
  2. Run it: cd TodoApi, dotnet run, then open https://localhost:5001 or the URL shown in the console.
  3. Explore minimal APIs and controllers; Swagger/OpenAPI is included by default for quick exploration.

Configuration and DI essentials

  • Configuration comes from appsettings.json, environment variables, and other providers.
  • Dependency injection is built in; register services in Program.cs with builder.Services.Add... and consume them via constructor injection.
  • Use IConfiguration, ILogger, and the options pattern for maintainable apps.

Next steps

  • Read the official guides: Microsoft Learn for .NET.
  • List templates: dotnet new list.
  • Publish for deployment: dotnet publish -c Release (framework-dependent) or add --self-contained for self-contained binaries.
  • Check your environment: dotnet --info.

More articles ยท Contact Santhor