Share this post


Playing with .NET 6 preview, C# 10 and Docker

As you may know, .NET 6 is coming on November 2021 this year and since //Build 2021 announcements the SDK & runtime previews are getting a a lot of great stuff coming. Here are some and some interesting links to keep an eye on.

Long time, no blogging!

It has been a while from last time I blogged. I’m really having a great time and fun since I joined Microsoft to work remotely, and it’s always great to take some time back on my notes to share some cool tech with the community. This time, .NET 6 stuff!

ICYMI: Here is the link to my previous post on joining Microsoft: 2020/12/07/Work at an awesome place. I’m joining Microsoft!

Play with dotnet 6 and docker

Let’s get started.

Here is a summary of what’s coming with .NET 6 tooling:

  • C# 10 preview features
  • Minimal APIs support
  • Linq & EF Core 6 previews
  • And more to come

At the time of publishing this post, there are 6 official previews released of .NET 6 (with Preview 7 going out soon!). The good thing is that tooling is going pretty much the same across those (VS Code support, dotnet build, run, etc) while Hot Reload is coming across .NET and Visual Studio 2022 on 64bit is now on Preview!

If you want to give it a try, I took some time to put it altogether in a new GitHub repo, which can be used with GitHub Codespaces and Docker so you don’t have to install locally in your machine!

.NET 6 preview repo

There are two ways for using the repo:

  1. GitHub Codespaces: If you have GitHub account with Codespaces support (public preview available, going GA soon!), you can just open it from “Code” button, then > “Open with Codespaces”. Tip: You can use the repo as a template for creating your own repo!
  2. ** Fork/clone locally**: You can use VSCode with the repo and install the Visual Studio Code Remote Development extension, Docker and open the folder in container.

More details: Visual Studio Code Remote Development

By opening from GitHub either VS Code (latest version preferarly) you would be ready to go!

Project structure & samples

  • /ConsoleApp (Minimal Console app with C# 10 / .NET 6 support)
  • /ConsoleApp.EntityFramework (.NET 6 + EF with SQLite)
  • /ConsoleApp.Linq (Some new LINQ coming features, no EF)
  • /WebApi (Minimal Web API with C# 9 / .NET 6)
  • /WebApi-Swagger (Minimal Web API with swagger support)
  • CI Dockerfile (yes! We have NuGet support and Docker SDK and Runtime images available!)
  • GitHub Actions with .NET 6

Creating a new Minimal Web API

dotnet new web -o src/WebApi

Here is how the Program.cs file looks like:

Then Run it

dotnet run --project WebApi/WebApi.csproj

Important: If you are running it from GitHub Codespace, make sure you have dotnet in your $PATH

export DOTNET_ROOT=$HOME/dotnet \ && export PATH=$PATH:$HOME/dotnet

C# 10 Global usings

With C# 10 you can place usings into a separate file (e.g Usings.cs) and keep the compiler happy across your clases. Event better, duplicated using statements can be removed and put them in 1 single file:

Getting some hands on GitHub Actions .NET 6

You can take advantage of the .NET 6 preview builds and use them as Docker images from Docker Hub. Both SDK and Runtime can be used accordingly:

Running the GitHub action

Make sure to put it under /.github/workflows folder so it can be executed automatically on every push on the repo.

Here is my dotnet6-docker-build.yml file output:

GitHub Action 1

.NET 6 Preview blogs:

Don’t forget to open issues in the stvansolano/dotnet6-preview repo in case something may need ny attention, and if you like it, give it a star. Happy coding!

P.D: I would be making progress and introduce changes in the repo as new previews got out. So stay refreshing/F5-ing!


Share this post

  • My photo
  • MS MVP logo
  • MVP logo

Software Engineer at Microsoft | Former MVP, Certified developer
More about me

 Recent postsExam passed! Microsoft AI Fundamentals AI-900 CertificationPlaying with .NET 6 preview, C# 10 and DockerWork at an awesome place. I'm joining Microsoft!Primer vistazo a .Net Maui (con codigo incluido)Creating your first GitHub codespace for F# and .Net 5.0Resumen y contenidos de mi charla - Mockeando tus APIs con C# y Xamarin DotNet Conf LatamMobile Workshop (Online): Xamarin Intro (2020)Resumen y contenidos - Xamarin Assemble 2020 edicion online! 🙉⚡📱Guia de CSharp 8 y NET 5: primeros pasos y recomendacionesResumen y contenidos charla DotNetConf Latam 2020: Xamarin Real-time mobile apps con CosmosDB y SignalR

 Browse by tag









 Open Source




















 Web Apps








 Web API


















































 Asp.Net Core














 UX / UI