{"id":44742,"date":"2023-11-20T14:31:33","date_gmt":"2023-11-20T14:31:33","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=44742"},"modified":"2024-05-08T15:06:04","modified_gmt":"2024-05-08T15:06:04","slug":"install-dotnet-8-ubuntu-22-04","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2023\/11\/install-dotnet-8-ubuntu-22-04\/","title":{"rendered":"How to Install .NET 8 in Ubuntu 22.04 LTS"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/dotnet-icon.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-44743\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/dotnet-icon-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/dotnet-icon-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/dotnet-icon-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/dotnet-icon-600x600.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/dotnet-icon-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/dotnet-icon.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p><b>UPDATE May 2024: .NET 8 is finally made into Ubuntu 22.04 main repository!! Just open terminal (Ctrl+Alt+T) and run 2 commands one by one to install:<\/b><\/p>\n<pre>sudo apt update<\/pre>\n<pre>sudo apt install dotnet8<\/pre>\n<p>Microsoft announced .NET 8 a few days ago. Here&#8217;s a step by step guide shows how to install it in Ubuntu 22.04 LTS (Also works in Ubuntu 20.04).<\/p>\n<p>.NET 8 is a new LTS release with 3 years support. It features new code generator \u201cDynamic Profile-Guided Optimization\u201d (PGO), AVX-512 instruction set, out-of-the-box AI features, first preview of .NET Aspire, native AoT, and various other changes. See the <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/announcing-dotnet-8\/\" target=\"_blank\" rel=\"noopener\">release note<\/a> for details.<\/p>\n<p>And, here are 2 ways to install the .NET 8 in current Ubuntu 22.04 LTS. They are Microsoft&#8217;s official repository and Ubuntu PPA.<\/p>\n<h3>Option 1: Install .NET 8 SDK\/Run-time via official repository<\/h3>\n<p>Ubuntu has included the new release package into system repository for Ubuntu 23.10 and next Ubuntu 24.04.<\/p>\n<p>Don&#8217;t know if it will be backported to Ubuntu 22.04 LTS repository, but here you can install it through Microsoft&#8217;s official apt repository. And, the repository also supports Ubuntu 20.04!<\/p>\n<p><b>1. install the key<\/b><\/p>\n<p>To add the Microsoft repository, you have to first download &amp; install the key file.<\/p>\n<p>To do so, press <b>Ctrl+Alt+T<\/b> on keyboard to open terminal. When terminal opens, run single command:<\/p>\n<pre>sudo wget -O - https:\/\/packages.microsoft.com\/keys\/microsoft.asc | gpg --dearmor | sudo tee \/etc\/apt\/keyrings\/microsoft.gpg<\/pre>\n<p><i>This command will download the key, dearmor it (so it&#8217;s unreadable code, see the screenshot), and save to &#8216;\/etc\/apt\/keyrings&#8217; directory.<\/i><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/microsoft-keyring.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44744\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/microsoft-keyring-600x407.webp\" alt=\"\" width=\"600\" height=\"407\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/microsoft-keyring-600x407.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/microsoft-keyring-300x203.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/microsoft-keyring-768x521.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/microsoft-keyring.webp 786w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p><b>2. Add the Microsoft repository<\/b><\/p>\n<p>Next, in terminal window, run command to create &amp; edit the sources file:<\/p>\n<pre>sudo gedit \/etc\/apt\/sources.list.d\/microsoft.sources<\/pre>\n<p><i>Depends on your desktop environment, replace <code>gedit<\/code> with <code>mousepad<\/code> for XFCE, <code>pluma<\/code> for MATE, or <code>nano<\/code> that works in most cases.<\/i><\/p>\n<p>When the file opens, add following lines and save it.<\/p>\n<pre>Types: deb\r\nURIs: https:\/\/packages.microsoft.com\/ubuntu\/<b>22.04<\/b>\/prod\/\r\nSuites: <b>jammy<\/b>\r\nComponents: main\r\nArchitectures: amd64\r\nSigned-By: \/etc\/apt\/keyrings\/microsoft.gpg<\/pre>\n<p><i>For Ubuntu 20.04, replace <code>22.04<\/code> with <code>20.04<\/code>, and <code>jammy<\/code> with <code>focal<\/code><\/i>.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/microsoft-sources-jammy.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44745\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/microsoft-sources-jammy-600x306.webp\" alt=\"\" width=\"600\" height=\"306\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/microsoft-sources-jammy-600x306.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/microsoft-sources-jammy-300x153.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/microsoft-sources-jammy-768x392.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/microsoft-sources-jammy.webp 894w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p><b>3. Install .NET 8<\/b><\/p>\n<p>Finally, update system package cache by running command:<\/p>\n<pre>sudo apt update<\/pre>\n<p>And, install .NET 8 SDK, runtime:<\/p>\n<pre>sudo apt install dotnet-sdk-8.0<\/pre>\n<p>I&#8217;m not .NET developer, but you can try <code>dotnet --version<\/code> after installation to verify.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/apt-dotnet8.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44747\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/apt-dotnet8-600x407.webp\" alt=\"\" width=\"600\" height=\"407\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/apt-dotnet8-600x407.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/apt-dotnet8-300x203.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/apt-dotnet8-768x521.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/apt-dotnet8.webp 786w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<h3>Option 2: Install .NET 8 from Ubuntu PPA<\/h3>\n<p>For choice, .NET 8 is also available to install through an <a href=\"https:\/\/launchpad.net\/~dotnet\/+archive\/ubuntu\/dotnet8\" target=\"_blank\" rel=\"noopener\">Ubuntu PPA<\/a>. It so far supports Ubuntu 22.04 on amd64 (Intel\/AMD) and arm64 (e.g., Raspberry Pi) devices.<\/p>\n<p><b>This is a third-party PPA, but maintained by the same people who maintain the .NET8 package in Ubuntu&#8217;s system repository for 23.10 &amp; 24.04.<\/b><\/p>\n<p>1. First, press <code>Ctrl+Alt+T<\/code> on keyboard to open terminal. When it opens, run command to add the PPA:<\/p>\n<pre>sudo add-apt-repository ppa:dotnet\/dotnet8<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/dotnet8-ppa.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-45448\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/dotnet8-ppa-700x469.webp\" alt=\"\" width=\"610\" height=\"409\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/dotnet8-ppa-700x469.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/dotnet8-ppa-300x201.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/dotnet8-ppa.webp 768w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><br \/>\n2. Linux Mint 21 users need to manually refresh the package cache after adding PPA, by running command:<\/p>\n<pre>sudo apt update<\/pre>\n<p>3. Finally, just run command to install .net8:<\/p>\n<pre>sudo apt install dotnet8<\/pre>\n<p>The command will install the host, sdk, runtime, as well as other packages automatically as dependencies.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/apt-dotnet8-ppa.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-45447\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/apt-dotnet8-ppa-700x469.webp\" alt=\"\" width=\"610\" height=\"409\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/apt-dotnet8-ppa-700x469.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/apt-dotnet8-ppa-300x201.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/11\/apt-dotnet8-ppa.webp 768w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<h3>Uninstall .NET 8<\/h3>\n<p>To remove .NET 8, open terminal (Ctrl+Alt+T) and run command:<\/p>\n<pre>sudo apt remove --autoremove aspnetcore-runtime-8.0 dotnet-sdk-8.0 dotnet-runtime-8.0 dotnet8<\/pre>\n<p>And, remove the Microsoft repository by running the 2 commands below to delete sources and key files:<\/p>\n<pre>sudo rm \/etc\/apt\/keyrings\/microsoft.gpg<\/pre>\n<pre>sudo rm \/etc\/apt\/sources.list.d\/microsoft.sources<\/pre>\n<p>Finally, run <code>sudo apt update<\/code> to refresh cache.<\/p>\n<p>If you installed the package from Ubuntu PPA, also run the <code>apt remove<\/code> command above to uninstall. Then, use the command below to remove the PPA:<\/p>\n<pre>sudo add-apt-repository --remove ppa:dotnet\/dotnet8<\/pre>","protected":false},"excerpt":{"rendered":"<p>UPDATE May 2024: .NET 8 is finally made into Ubuntu 22.04 main repository!! Just open terminal (Ctrl+Alt+T) and run 2 commands one by one to install: sudo apt update sudo apt install dotnet8 Microsoft announced .NET 8 a few days ago. Here&#8217;s a step by step guide shows how to install it in Ubuntu 22.04 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":44743,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[2090],"class_list":["post-44742","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-microsoft"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/44742","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=44742"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/44742\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/44743"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=44742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=44742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=44742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}