.NET NuGet

Updated: 30 June 2023

https://www.nuget.org/

Add a package

dotnet add package System.Data.OleDb --version 8.0.0-preview.5.23280.8

Remove package reference from a project file.

dotnet remove package System.Data.OleDb

Lists the package references for a project or solution.

dotnet list package

.NET

Updated: 29 January 2023

.NET is an open source developer platform (i.e. the Languages & Libraries) for building different types of apps. The supported languages are C#, Visual Basic and F#.

Target platforms are:

  • .NET Core which runs on Windows, Linux and macOS.
  • .NET Framework for websites, services and apps on Windows only.
  • Xamarin / Mono, a .NET for mobile e.g. iOS devices, Apple Watch/TV Android.

https://docs.microsoft.com/dotnet
https://aka.ms/dotnethelloworld

 

The Host

A container which offers built-in services:

  • Dependency injection – a technique for achieving Inversion of Control between classes and their dependencies.
  • Configuration
  • Logging
  • Options pattern
  • Host Services

.NET 6 offers Generic DefaultHost which can be configured for the application use cases.

Hosted Service

A service which performs work in the background. Any reference type object which implements IHostedService is a background / hosted / worker service.

DI Service Container

Class dependencies can be registered in a service container.

.NET provides a built-in service container, IServiceProvider. Services are typically registered at the app’s start-up and appended to an IServiceCollection. Once all services are added BuildServiceProvider is used to create the service container.

Dependency Injection injects the service into the constructor of the class where it’s needed. The framework takes on the responsibility of creating an instance of the dependency and disposing of it when it’s no longer needed.

.NET CLI

Updated: 08 December 2024

new

Create a new .NET project based on the console template.

dotnet new console --name our_project

run

Build and test the Release version of a console application

dotnet run --configuration Release

test

Run the tests in the project in the current directory

dotnet test

clean

Clean up the output of the previous build. Both intermediate (obj) and final output (bin) folders are cleaned.

dotnet clean

restore

Restores the dependencies and tools for a project i.e. external libraries in NuGet packages. All dependencies become available in a local cache and can be used by the .NET CLI to build and run the application.

dotnet restore

dotnet

List installed Software Developer Kits

dotnet --list-sdks

List installed runtimes

dotnet --list-runtimes

build

Build a project and its dependencies using Release configuration

dotnet build --configuration Release

Build the project and its dependencies into a set of binaries. The binaries include the project’s code in Intermediate Language (IL) files with a .dll extension.

dotnet build

publish

Publishes the application and its dependencies to a folder for deployment to a hosting system.

dotnet publish

Attempt to target Linux (not tested)

dotnet publish --configuration release --runtime linux-x64 --self-contained

Attempt to target Linux (not tested)

dotnet publish --runtime linux-x64 -p:PublishSingleFile=true --self-contained false