How to upgrade your ASP.NET Core web project to .NET6
.NET 6 Release Candidate 1 has been announced on September 14th, 2021 https://devblogs.microsoft.com/dotnet/announcing-net-6-release-candidate-1/
I’ve just updated my ASP.NET Core web projects from .NET5 to the new .NET6-rc.1 and published to the production server . Here are the steps that I applied for my DevOps pipeline.
Check out the development we’ve made for .NET 6 migration https://github.com/abpframework/abp/pull/9700
1- Install the new .NET SDK to your development computer. https://dotnet.microsoft.com/download/dotnet/6.0
2- Install the new .NET Runtime to your production server.
https://dotnet.microsoft.com/download/dotnet/6.0
If you are on Windows machine, it’s suggested to install the Hosting Bundle
3- Update the Dockerfile
in each website.
If you are using Docker, you need to update the Docker images. You can get the image tags from https://hub.docker.com/_/microsoft-dotnet-aspnet/
Open Dockerfile
in your web project (or any publishable projects) and
Remove:
FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base
Add:
FROM mcr.microsoft.com/dotnet/aspnet:6.0.0-rc.1-bullseye-slim AS base
UPDATE: As .NET6 stable version has been released you can use the new Docker image
mcr.microsoft.com/dotnet/aspnet:6.0.0-bullseye-slim
Our build server is an Ubuntu distro that’s why I will also explain my experience installing .NET SDK to Ubuntu. Note that I am not familiar to Linux/Unix OS that’s why writing this basic steps for anyone like me.
How to install the .NET SDK 6 preview to Ubuntu
If your server is Ubuntu, then you can install the new SDK following the steps below:
mkdir $HOME/dotnet_install && cd $HOME/dotnet_install
curl -L https://aka.ms/install-dotnet-preview -o install-dotnet-preview.sh
- Run the shell script with
sudo bash install-dotnet-preview.sh
mkdir -p $HOME/dotnet && tar zxf dotnet.tar.gz -C $HOME/dotnet
export PATH=$PATH:$HOME/dotnet
sudo dpkg -i dotnet-host-6.0.0-rc.1.21451.13-x64.deb
sudo dpkg -i dotnet-hostfxr-6.0.0-rc.1.21451.13-x64.deb
sudo dpkg -i dotnet-runtime-6.0.0-rc.1.21451.13-x64.deb
sudo dpkg -i aspnetcore-runtime-6.0.0-rc.1.21452.15-x64.deb
sudo dpkg -i aspnetcore-targeting-pack-6.0.0-rc.1.21452.15.deb
sudo dpkg -i dotnet-apphost-pack-6.0.0-rc.1.21451.13-x64.deb
sudo dpkg -i dotnet-runtime-deps-6.0.0-rc.1.21451.13-x64.deb
sudo dpkg -i dotnet-targeting-pack-6.0.0-rc.1.21451.13-x64.deb
sudo dpkg -i netstandard-targeting-pack-2.1_2.1.0–1_amd64.deb
sudo dpkg -i dotnet-sdk-6.0.100-rc.1.21458.32-x64.deb
Check the dotnet version with the following command:
dotnet — version
I’m Alper Ebicoglu 🧑🏽💻 ABP Framework Core Team Member
Follow me for the latest news about .NET and software development:
📌 twitter.com/alperebicoglu
📌 github.com/ebicoglu
📌 linkedin.com/in/ebicoglu
📌 medium.com/@alperonline