.NET 6

I don’t really talk about .NET on this blog, but I am very interested in .NET 6. I used to be a .NET developer and I used to write Windows Form applications, WPF, Windows Service and ASP .NET applications. The reason I have been away from .NET is because the current company I work for mainly uses Linux technology. (I applied for the job because I was very interested in the Linux realm.)

I am interested in .NET 6 (as of 9/13/2021, it is in preview 7) because it has a new feature of multi platform UI. When I develop software in the last few years, I have always cared for multi platform-ness. I tried Electron for the software I developed in WPF but it didn’t click with me because it’s mainly HTML and JavaScript. I should have pursued it but the thing is that I miss C# very much.

I downloaded the .NET 6 installer for macOS and installed it. After the installation, I opened terminal and ran dotnet. Here is the output I got.

I want to make sure I am using .NET 6 preview 7. So I run dotnet --version and I got the following output.

Now I am going to create a sample code. I run dotnet new --list to list the available project type.

I’m going to create a hello world sample code in console application. I run dotnet new console helloworld to create the sample project

Once dotnet new console helloworld is successful, you get a few files like this.

The Program.cs file already has a sample code like below.

// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!"); 

To compile the code, you can run dotnet build in the same directory.

Once the compilation is successful, it creates bin/Debug/net6.0 directories. In net6.0 directory, it generates several compiled files like below.

As shown in the image, helloworld is an executable file, so you can be in net6.0 directory and execute it like ./helloworld But you can go back to 3 directories up and execute it like dotnet run.

According to the help, dotnet run builds and runs the project, so when you make changes to the code, you could just execute dotnet run to test things out.

I will continue to .NET 6 as time permits.

Author: admin

A software engineer in greater Seattle area

Leave a Reply

Your email address will not be published. Required fields are marked *