Home

ITA - Installazione manuale di dotnet

dev fedora c

Io voglio poter decidere volta per volta quale versione di dotnet usare quando compilo un programma scritto in C#.

Configurazione

Installazione di dotnet

dotnet SDK v2.1.811

$ sudo mkdir -p /opt/dot/net/2.1.811/
$ wget https://download.visualstudio.microsoft.com/download/pr/4281b67c-db32-4e7e-aa67-976a59839b81/75373c7621c37c2ac7a83fc60d415afd/dotnet-sdk-2.1.811-linux-x64.tar.gz
$ sudo tar -xf dotnet-sdk-2.1.811-linux-x64.tar.gz -C /opt/dot/net/2.1.811/

dotnet SDK v3.1.404

$ sudo mkdir -p /opt/dot/net/3.1.404/
$ wget https://download.visualstudio.microsoft.com/download/pr/ec187f12-929e-4aa7-8abc-2f52e147af1d/56b0dbb5da1c191bff2c271fcd6e6394/dotnet-sdk-3.1.404-linux-x64.tar.gz
$ sudo tar -xf dotnet-sdk-3.1.404-linux-x64.tar.gz -C /opt/dot/net/3.1.404/

dotnet SDK v5.0.101

$ sudo mkdir -p /opt/dot/net/5.0.101/
$ wget https://download.visualstudio.microsoft.com/download/pr/a0487784-534a-4912-a4dd-017382083865/be16057043a8f7b6f08c902dc48dd677/dotnet-sdk-5.0.101-linux-x64.tar.gz
$ sudo tar -xf dotnet-sdk-5.0.101-linux-x64.tar.gz -C /opt/dot/net/5.0.101/

Configurazione di Environment modules

Nella mia installazione di sistema ho deciso di mettere i moduli dei programmi installati sotto opt nella cartella /opt/modulefiles.

Creazione dei file di modulo

dotnet SDK v2.1.811

::::::::::::::
/opt/modulefiles/dotnet/2.1.811
::::::::::::::
#%Module1.0#####################################################################
##
## dotnet 2 modulefile
##

conflict dotnet
prepend-path PATH /opt/dotnet/2.1.811/

dotnet SDK v3.1.404

::::::::::::::
/opt/modulefiles/dotnet/3.1.404
::::::::::::::
#%Module1.0#####################################################################
##
## dotnet 3 modulefile
##

conflict dotnet
prepend-path PATH /opt/dotnet/3.1.404/

dotnet SDK v5.0.101

::::::::::::::
/opt/modulefiles/dotnet/5.0.101
::::::::::::::
#%Module1.0#####################################################################
##
## dotnet 5 modulefile
##

conflict dotnet
prepend-path PATH /opt/dotnet/5.0.101/

Esempio d’uso

[stethewwolf@hel ~]$ module avail
---------------------- /opt/modulefiles -------------------------------
dotnet/2.1.811 dotnet/3.1.404 dotnet/5.0.101  

---------------------- /usr/share/modulefiles ----------------------------
mp-x86_64  
$ module load dotnet/5.0.101 
$ dotnet --version
5.0.101
$ module load dotnet/3.1.404 
Loading dotnet/3.1.404
  ERROR: dotnet/3.1.404 cannot be loaded due to a conflict.
    HINT: Might try "module unload dotnet" first.
$ module unload dotnet/5.0.101
$ module load dotnet/3.1.404 
$ dotnet --version
3.1.404
$ 

Riferimenti