Skip to main content

.NET-Core - First steps

Konfiguration

Proxy

Sitzt der Linux-Rechner hinter einem Proxy, so muss apt-key und apt-get dies beigebracht werden.

apt-get

Der Paketemanager benutzt Konfigurationsdateien, um die Proxy-Konfiguration zu lesen.

In dem Verzeichnis /etc/apt/apt.conf.d die Datei 30proxy anlegen.

cd /etc/apt/apt.conf.d
touch 30proxy

In die Datei die Informationen des Proxys eingeben.

Acquire::http::proxy "http(s)://USERNAME:PASSWORT@ADDRESSE:PORT/";
Acquire::https::proxy "http(s)://USERNAME:PASSWORT@ADDRESSE:PORT/"; 

apt-key

Der Keymanager bedient sich leider nicht der apt-get-Konfigurationsdateien. Der Proxy wird einfach in die env exportiert.

export http_proxy="http(s)://USERNAME:PASSWORT@ADDRESSE:PORT/"
export https_proxy="http(s)://USERNAME:PASSWORT@ADDRESSE:PORT/"

Installation


Quelle: https://www.microsoft.com/net/core#linuxubuntu

Add the dotnet apt-get feed

In order to install .NET Core on Ubuntu or Linux Mint, you need to first set up the apt-get feed that hosts the package you need.

Ubuntu 14.04 / Linux Mint 17

sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893
sudo apt-get update

Ubuntu 16.04 / Linux Mint 18

sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893
sudo apt-get update

Ubuntu 16.10

sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ yakkety main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893
sudo apt-get update

Install .NET Core SDK

Before you start, please remove any previous versions of .NET Core from your system by using this script.

To install .NET Core 1.1 on Ubuntu or Linux Mint, simply use apt-get.

.NET Core 1.1 is the latest version. For long term support versions and additional downloads check the all Linux downloads section.

sudo apt-get install dotnet-dev-1.0.4

Initialize some code

Let's initialize a sample Hello World application!

dotnet new console -o hwapp
cd hwapp

Run the app from scratch

The first command will restore the packages specified in the project file, and the second command will run the actual sample:

dotnet restore
dotnet run

Run the app under Unix or Windows

dotnet "/path/to/dll" "PARAMETER1" "PARAMETER2"

Script zum Deploy

Hinweis
PROJEKTNAME
USERFOLDER
user@server:~$ cat deploy.sh
#!/bin/bash
  
HOMEDIR="/home/_USERFOLDER_"
PROJECTDIR="$HOMEDIR/_PROJEKTNAME_/_PROJEKTNAME_"
  
export http_proxy="http(s)://USERNAME:PASSWORT@ADDRESSE:PORT/"
export https_proxy="http(s)://USERNAME:PASSWORT@ADDRESSE:PORT/"
  
cd $PROJECTDIR
dotnet restore
dotnet build