User Tools

Site Tools


notes:tools:netcore

.NET Core

Create a console app called 'ConsoleApp':

md ConsoleApp
cd ConsoleApp
dotnet new console

Create a library called 'ClassLib':

md ClassLib
cd ClassLib
dotnet new classlib

Create an NUnit3 test project:

md TestProj
cd TestProj
dotnet new nunit

Add a project reference:

cd TestProj
dotnet add reference "..\ConsoleApp\ConsoleApp.csproj"

Show help on how to add references:

dotnet add reference -h
dotnet add package -h

Run tests:

cd TestProj
dotnet test

dotnet commands:

dotnet --version
dotnet --help
dotnet run                       # build and execute .csproj in the current folder
dotnet <command> -h              # get CLI help
dotnet help <command>            # get on-line help
dotnet <command> -v diag         # run diagnostics
dotnet add app.csproj reference lib.csproj  # add p2p reference to app.csproj
# FDD - framework-dependent deployment
dotnet publish -c Release        
 
# SCD - self-contained deployment; publish a self-contained package for a specific platform
# RID - runtime identifier: [os].[version]-[arch]
# RID has to be also specified in csproj's RuntimeIdentifier or RuntimeIdentifiers element.
dotnet publish -c Release -r ubuntu.16.04-x64

Install prerequisites for SCD on Ubuntu:

apt update
apt install -y libunwind8 libunwind8-dev gettext libicu-dev liblttng-ust-dev libcurl4-openssl-dev uuid-dev unzip

'which dotnet' displays the path to dotnet on Linux or Mac:

  • Linux: /usr/bin/dotnet
  • Mac: /usr/local/share/dotnet

Folders with dotnet SDK:

  • Windows: C:\Program Files\dotnet\sdk
  • Linux: /usr/bin/dotnet/sdk (error???: “dotnet - not a directory”; maybe because it's in a container)
  • Mac: /usr/local/share/dotnet/sdk

Location of .NET Core installations

  • Windows: C:\Program Files\dotnet\shared
  • 2.0.7, 2.0.9, 2.1.2

Links

notes/tools/netcore.txt · Last modified: 2018/10/11 by leszek