Inhaltsverzeichnis

.NET

https://dotnet.microsoft.com/

Nice to Know

Sprachen

Telemetrie

Auswählen der .NET Version zum Ausführen von Programmen

Unterschiede

.NET Framework

.NET Core

.NET

Vorraussetzungen

https://docs.microsoft.com/dotnet/core/tutorials/

Projekte im SDK-Style

Beispiel C# Web-Projekt (ASP.NET Core)

test.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
 
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <AnalysisLevel>latest</AnalysisLevel>
    <AnalysisMode>all</AnalysisMode>
    <EnableNETAnalyzers>true</EnableNETAnalyzers>
    <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
  </PropertyGroup>
 
  <ItemGroup>
    <PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>
 
</Project>

Einrichten der Entwicklungsumgebung (Ubuntu)

.NET installieren

> wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
> sudo dpkg -i packages-microsoft-prod.deb
> rm packages-microsoft-prod.deb

SDK installieren

Runtime ist bereits im SDK vorhanden

> sudo apt-get update && sudo apt-get install -y dotnet-sdk-6.0

Runtime installieren

> sudo apt-get update && sudo apt-get install -y aspnetcore-runtime-6.0

Erstes Projekt mit Visual Studio Code

$ mkdir ~/projects/my-project
$ cd ~/projects/my-project
$ dotnet new sln                # a dotnet solution can contain multiple projects
$ dotnet new console --name my-console-app
$ dotnet sln my-project.sln add my-console-app/my-console-app.csproj
$ cd my-console-app
$ dotnet restore                # restore nuget packages
$ dotnet build
$ dotnet run
$ cd ..
$ code .                        # open entire solution in vs code and start developing

Für Publish siehe https://docs.microsoft.com/dotnet/core/tutorials/publishing-with-visual-studio-code

Im RID-Katalog findet man die RuntimeIdentifier, um .NET Applikationen für eine bestimmte Plattform zu kompilieren.