Tuesday, August 15, 2023

Dotnet SDK installation using package manager CLI in Windows and Linux

#### Install .NET updates using the Windows Package Manager CLI (winget):


 - Install the .NET 7 sdk 

```sh
	winget install dotnet-sdk-7
```

 - Install the .NET 7 runtime, run 

```sh
	winget install dotnet-runtime-7

```

 - To update an existing installation: 

```sh

	winget upgrade
    
    winget upgrade --include-unknown 
```



  
 - Install dotnet SDK using packages in Linux 
  
 
```sh

#update all packages before install .net 

sudo apt update 

# following command will install dotnet core 2.1, 2.2, 3.0 and 3.1

sudo apt install dotnet-sdk*

# following command will install dotnet 6.0  if not able to find package then we can install using manuall steps using below steps 
sudo apt install dotnet-sdk-6.0

# following command will install dotnet 7.0  if not able to find package then we can install using manuall steps using below steps 
sudo apt install dotnet-sdk-7.0

#following command will install runtime
	sudo apt install dotnet-host

#following command will upgrade\update dotnet SDK package
sudo apt upgrade dotnet-sdk-7.0


#uninstall dotnet SDK packges using apt remove
sudo apt-get remove dotnet-sdk-6.0

sudo apt remove dotnet*
sudo apt remove netstandard*
sudo apt remove aspnetcore*

```




###  Install dotnet 6.0  7.0 SDK in Linux using manual steps 

```sh
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
chmod +x ./dotnet-install.sh


# following command will install dotnet  6.0 version
./dotnet-install.sh --version latest


# following command will install dotnet  7.0 version
./dotnet-install.sh --channel 7.0

#Add below environment variable to add dotnet path in path variable 

export DOTNET_ROOT=$HOME/.dotnet

export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools

#Note- add these environment variables in   ~/.bashrc ~/.profile to avoid define these variables for each linux instance
```


###  Install dotnet 8.0 preview SDK in Linux using manual steps 


```sh
# following command will install dotnet  8.0 preview version

wget https://download.visualstudio.microsoft.com/download/pr/32f2c846-5581-4638-a428-5891dd76f630/ee8beef066f06c57998058c5af6df222/dotnet-sdk-8.0.100-preview.7.23376.3-linux-x64.tar.gz -O  dotnet-sdk-8.0.100-preview.7.23376.3-linux-x64.tar.gz

mkdir -p $HOME/.dotnet && tar zxf dotnet-sdk-8.0.100-preview.7.23376.3-linux-x64.tar.gz -C $HOME/.dotnet

export DOTNET_ROOT=$HOME/.dotnet

export PATH=$PATH:$HOME/.dotnet

```
### Install project templates using dotnet CLI in windows \Linux 

```sh 
# syntax 

dotnet new install <TemplateName>

# we can install templates for chat bot projects using dotnet cli in windows\linux

dotnet new install Microsoft.Bot.Framework.CSharp.CoreBot

dotnet new install Microsoft.Bot.Framework.CSharp.EmptyBot

dotnet new install Microsoft.Bot.Framework.CSharp.EchoBot


# we can install templates for clean Architecture  using dotnet cli in windows\linux

dotnet new install Ardalis.CleanArchitecture.Template

dotnet new install Clean.Architecture.Solution.Template::8.0.0-preview.6.18


#  to list of installed templated 

dotnet new uninstall

```
### The .NET entity framework is  available as a .NET global tool. We can install the tool with the following command in windows \Linux OS

```sh
dotnet tool install --global dotnet-ef

```

### The .NET Upgrade Assistant is also available as a .NET global tool. We can install the tool with the following command in windows \Linux OS

```sh
	dotnet tool install -g upgrade-assistant
```

 - NET Upgrade Assistant is installed as a .NET tool, it can be easily updated by running following command in windows \Linux OS

```sh
    dotnet tool update -g upgrade-assistant
```

Now we can upgrade existing project to new .net framework

```sh
  #usage
	
  upgrade-assistant upgrade
  
  upgrade-assistant upgrade 
  
  upgrade-assistant upgrade  --operation Inplace --targetFramework net6.0
  
  upgrade-assistant upgrade  --operation SideBySide --targetFramework LTS --destination  
  
```





No comments:

Post a Comment