Popular blog tags

How to Install and uninstall reinstall upgrade .NET x on 20.04*64




Ubuntu 20.04*64


.Net 6.x

Install and uninstall reinstall  upgrade .NET 6.x
step 1:add the Microsoft package signing key to your list of trusted keys and add the package repository.
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
step 2:Install or upgrade the SDK
sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0
step 3:Install or upgrade the runtime
sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y aspnetcore-runtime-6.0
step 4:check
:~# dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.202
 Commit:    f8a55617d2

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  20.04
 OS Platform: Linux
 RID:         ubuntu.20.04-x64
 Base Path:   /usr/share/dotnet/sdk/6.0.202/

Host (useful for support):
  Version: 6.0.4
  Commit:  be98e88c76

.NET SDKs installed:
  6.0.202 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.4 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.4 [/usr/share/dotnet/shared/Microsoft.NETCore.App]





.net 6.x

dotnet workload uninstall maui
dotnet workload uninstall android
dotnet workload uninstall ios
dotnet workload uninstall maccatalyst


.net 2.x

step 1.发布网站 Build/publish Windows

dotnet publish -c  release

dotnet publish -c Release -f netcoreapp2.1 --manifest $env:


dotnet publish -c Release -f netcoreapp2.1 --manifest %JITBENCH_ASPNET_MANIFEST% (cmd)  

dotnet publish -c Release  

Step 2: Run the app

cd E:\Nopcommerce\MslyAspNetGrandNode40\src\Nop.Web\bin\Release\netcoreapp2.0\publish

dotnet Nop.Web.dll 发布后定位到publish目录使用 dotnet xx.dll 执行应用。

dotnet run -c Release Dotnet run --urls="http://域名:端口号"  如果想设置多个域名,可以使用分号分隔。

  Step 3:change port 5000 to other  

2. 发布控制台程序为exe 文件 net core 2.0程序默认生成的是一个dll,需要通过dotnet命令来执行他。

dotnet ConsoleApp1.dll 生成带exe的命令则是:--runtime <rid>    

 dotnet build --runtime win-x64

copy D:\Temp\ConsoleApp1\ConsoleApp1\bin\Release\netcoreapp2.1\win-x64\publish下所有文件到另外机器 CMD run ConsoleApp1.exe    



dotnet publish -c Release -r win-x64 --self-contained


.Net 6.x     2021/11/12

dotnet run -c Release -f net48 -filter "**" --runtimes net48 net5.0 net6.0


Useful links


Check OS Environment

#lsb_release -a


# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.4 LTS
Release:	20.04
Codename:	focal

Clean up the Cache and Obsolete Files

sudo apt autoremove
sudo apt clean