Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
vermeir_nico_introducing_net_6_getting_started_with_blazor_m.pdf
Скачиваний:
19
Добавлен:
26.06.2023
Размер:
11.64 Mб
Скачать

Chapter 1 A Tour of .NET 6

\3.\ User story: An explanation of the feature written from the perspective of the end user. Its purpose is to articulate how a software feature will provide value to the customer. Once

implemented, it will contribute value toward the overall epic. For example, “As an IT Pro, I have easy access to .NET Core installer release information and scripts in my air gapped environment so I can use this to determine which updates need to be deployed.”

\4.\ Issue: These are all other work items. These could be bugs, features, or developer tasks. We leave it up to the engineering team/area owner how and if they want to use these.

Supported Operating Systems

Since .NET is a cross-platform framework, there are a multitude of operation systems supported. Support ranges from Windows to Linux, macOS, Android, iOS, and

tvOS. Table 1-2 lists the different versions of Windows that support .NET 6.

Table 1-2.  Versions of Windows that support .NET 6

Operating system

Version

Architecture

 

 

 

Windows

7 SP1, 8.1

x64, x86

Windows 10

Version 1607+

x64, x86, ARM64

Windows 11

Version 22000+

x64, x86, ARM64

Windows Server

2012+

x64, x86

Windows Server Core

2012+

x64, x86

Nano Server

Version 1809+

x64

 

 

 

Table 1-3 lists the supported Linux distributions with the supported versions and architecture.

6

 

 

Chapter 1 A Tour of .NET 6

Table 1-3.  Linux versions that support .NET 6

 

 

 

 

Operating system

Version

Architecture

 

 

 

 

Alpine Linux

3.13+

x64, ARM64, ARM32

CentOS

7+

x64

Debian

10+

x64, x86, ARM64, ARM32

Fedora

33+

x64

openSUSE

15+

x64

Red Hat Enterprise Linux

7+

x64, ARM64

SUSE Enterprise Linux

12 SP2+

x64

Ubuntu

16.04, 18.04, 20.04+

x64, ARM64, ARM32

 

 

 

 

Table 1-4 lists the supported versions and architectures for macOS.

Table 1-4.  macOS versions that support .NET 6

Operating system

Version

Architecture

 

 

 

macOS

10.15+

x64, ARM64

 

 

 

Table 1-5 lists the supported versions and architectures for Android.

Table 1-5.  Android versions that support .NET 6

Operating system

Version

Architecture

 

 

 

Android

API 21+

x64, ARM, ARM64

 

 

 

Table 1-6 lists the supported versions and architectures for iOS and tvOS.

Table 1-6.  iOS and tvOS versions that support .NET 6

Operating system

Version

Architecture

 

 

 

iOS

10.0+

x64, ARM, ARM64

tvOS

10.0+

x64, ARM, ARM64

 

 

 

7

Chapter 1 A Tour of .NET 6

The above tables list supported operating systems, versions, and architectures at the time of writing. The most up-to-date version of this list for .NET 6 is available at https:// github.com/dotnet/core/blob/main/release-notes/6.0/supported-os.md.

Command Line Interface

.NET ships with a powerful Command Line Interface (CLI) tooling system since .NET Core. With the .NET command line, we can do things like creating a new project, installing tools and templates, running tests, compiling, and much more. While most of the CLI commands are rarely used manually, we can use them to script build and deploy automation. Tools like Azure DevOps or GitHub actions have full support for these commands.

The basic commands consist of:

•\ New

•\ Restore

•\ Build

•\ Publish

•\ Run

•\ Test

•\ Vstest

•\ Pack

•\ Migrate

•\ Clean

•\ Sln

•\ Help

•\ Store

Before we use the CLI, we have to install .NET 6 on our machine. If you have Visual Studio 2022 installed, you might already have it up and running.

We can see what version of .NET we are currently running by opening up a Powershell prompt and executing dotnet –-version.

8

Chapter 1 A Tour of .NET 6

Figure 1-3.  Current installed version of .NET

If you get another version, maybe from .NET 5, you can download the .NET 6 installer from https://dotnet.microsoft.com/download/dotnet/6.0. Make sure to download and install the SDK to get the command line tooling.

Once .NET 6 is installed, we can see what project templates we have by executing dotnet new. The tooling will list all available options if we don’t specify a specific template as shown in Figure 1-4. The contents of this list depend of course on the different workloads and templates you have installed on your system.

Figure 1-4.  Available project templates in dotnet new

Let’s try to create, build, and run a .NET 6 WinForms application without any help from an IDE.

First we create the project by selecting the correct dotnet new template.

9

Chapter 1 A Tour of .NET 6

Figure 1-5.  Creating a WinForms project through command line

This command created a WinForms project called DotnetSixWinForms in the current directory. Just to verify that it really is a .NET 6 project, let’s have a look at the .csproj file.

Listing 1-1.  WinForms project file

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>

<OutputType>WinExe</OutputType> <TargetFramework>net6.0-windows</TargetFramework> <Nullable>enable</Nullable> <UseWindowsForms>true</UseWindowsForms> <ImplicitUsings>enable</ImplicitUsings>

</PropertyGroup>

</Project>

TargetFramework is set to net6.0-windows, so we’re running on .NET 6 using the Windows compatibility pack. The compatibility packs are explained in more detail in Chapter 2. For now it means that we are running on .NET 6 but referencing some extra binaries so we can hook into the native Windows APIs, for example, to render our application or access the filesystem. Next step, let’s build the project through dotnet build.

10

Chapter 1 A Tour of .NET 6

Figure 1-6.  Building the project through the command line

I first made sure my command line was set in the directory where the .csproj or .sln file lives. If this is the case, a simple dotnet build suffices. The tool looks for a .csproj or .sln in its current directory and starts building it. What is happening right now is the exact same thing that happens when we build a project in Visual Studio. We call the

.NET build system MSBuild and pass in parameters and a reference to a project, and it will start building. Once it is done building, you will find the familiar bin and obj folders in the project folder that you will also find after building from Visual Studio. There is no extra magic happening in Visual Studio; it triggers the same command we just executed manually.

As a final step, we execute dotnet run which will effectively build the project if necessary and launch it, showing a blank WinForms page as shown in Figure 1-7.

Figure 1-7.  Running a WinForms application from the command line

11