This is the 25th day of my participation in the August Genwen Challenge.More challenges in August
In the last year or two, I have done a lot of other things, mostly not.net Web. I have worked on a few small projects and learned some bits and pieces, but I haven’t really studied systematically since the release of.NET Core. Just start to do the project, usually there are concerns and read some information, so the project to write some business logic or no problem, recently pondering to systematically learn.net. Net core will not be called.NET X, so we will start with the current stable version of.NET 5. Since.NET 6 is not officially released and there will be no major changes to the system, it will probably be 6 sometime, so the title will be.net 5+. I don’t have much free time except for work and life, which may be a long learning process for me. Familiar words said at the beginning of the beneficial, I hope not eunuch, one is to make their own study notes so as not to forget, the second is to study with new students, is not unhappy. Our first step is to start with the.NET development environment.
.NET SDK and runtime
First let’s take a look at the.net SDK and runtime concepts.
The.NET SDK is a set of libraries and tools for developing and running.NET applications
The SDK download includes the following components:
- .net CLI. Command-line tools for local development and continuous integration scripts.
- Dotnet driver. CLI commands used to run frame-dependent applications.
- Roslyn and F# programming language compilers.
- MSBuild build engine.
- .NET runtime. Provides a type system, assembly loading, garbage collector, native interoperation, and other basic services.
- Runtime libraries. Provides primitive data types and basic utilities.
- ASP.NET Core runtime. Provides basic services for Internet-connected applications such as Web applications, IoT applications, and mobile backends.
- Desktop runtime. Provides basic services for Windows desktop applications, including Windows Forms and WPF.
The runtime download includes the following components:
- (optional) desktop or ASP.NET Core runtime.
- .NET runtime. Provides a type system, assembly loading, garbage collector, native interoperation, and other basic services.
- Runtime libraries. Provides primitive data types and basic utilities.
- Dotnet driver. CLI commands used to run frame-dependent applications.
Note the [runtime] and the [.NET runtime]. Runtimes are the ones included above, and.net runtimes are included within runtimes.
The.NET runtime is the CLR, the runtime library is the base class library (BCL), these names are confusing, maybe we usually say.net runtime ≈ runtime, but when understanding the concept should be clear.
The.NET CLR is a cross-platform runtime with Windows, macOS, and Linux support. The CLR handles memory allocation and management. The CLR is also a virtual machine that not only executes applications, but also generates and compiles code using a real-time JIT compiler. A runtime library is also called a framework library or base class library (BCL). These libraries provide implementations for many general-purpose types and workload specific types and utility functions.
You can see that the SDK includes the runtime, and one important thing the SDK includes is the CLI, which is a cross-platform tool chain for developing, generating, running, and publishing.NET applications. For example, CLI creates a C# console application project in the current directory:
dotnet new console
Copy the code
To put it simply, the SDK allows us to develop programs, and the runtime allows us to run written programs. Of course, installing the SDK does not require shipment. As an analogy to Java, the SDK is equivalent to the JDK and the runtime is equivalent to the JRE. Of course, we usually don’t use CLI because we have a better tool, Visual Studio.
The SDK installation
There are two ways to install the SDK. The first way is to install it together with the tool, and the second way is to download the SDK package to install it.
1. Install using Visual Studio
Visual Studio 2019 download
Minimum version of Visual Studio required for different target.NET SDK versions.
For.NET 5, a minimum of Visual Studio 2019 version 16.8 is required.
If you have Visual Studio installed, you can use the following steps to check your version. Open Visual Studio. Choose Help > Microsoft Visual Studio. Read the version number from the About dialog box.
I had Visual Studio 2019 installed locally and was going to test the installation by updating the VS. But I have a problem with the local environment VS, keep reporting errors.
If you don’t have it, you can download it directly and install it as required. I tinkered with it, I can’t fix it, I can’t upgrade it. So you end up having to reinstall, because.NET 5 supports 16.8 at a minimum, mine is 16.7! . If you cannot uninstall vs, use the Installer directory C: Program Files (x86) Microsoft Visual Studio Installer to run setup.exe and then start Installer installation.
2. Download and install it manually
Download the.net 5.0
This is the second way, if you don’t need VS, to download and install the SDK directly. You can then use the CLI to create projects, and few people would program without a tool, for no good reason.
.NET 5 project creation
Let’s look at creating the project after uninstalling and reinstalling Visual Studio 2019. Create a console application with two options, one for the.NET Framework and one for.net Core. I wonder if the official version of VS2022 will change the name, since it will no longer be called.net Core.
But when we select.net Core we can choose our target framework if we have multiple versions installed.
Now that our.NET 5 development environment is set up, next time we’ll explore the concepts and differences between.NET Framwork,.NET 5 and.NET Standard.