Unable to install specific version of .NET Core on Ubuntu images

Pure Krome's Avatar

Pure Krome

22 Aug, 2020 02:27 PM

Heya,

I'm trying to install a specific version of .netcore 3.1.6 onto a standard Ubuntu 16.4 image. (current image is 3.1.4)

So i tried to do this .. and it installed, but the image was not 'found':

Command: curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --runtime dotnet --version 3.1.6

curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --runtime dotnet --version 3.1.6
dotnet_install: Warning: Unable to locate zlib. Probable prerequisite missing; install zlib.(B
dotnet-install:(B Downloading link: https://dotnetcli.azureedge.net/dotnet/Runtime/3.1.6/dotnet-runtime-3.1.6-linux-x64.tar.gz
dotnet-install:(B Extracting zip from https://dotnetcli.azureedge.net/dotnet/Runtime/3.1.6/dotnet-runtime-3.1.6-linux-x64.tar.gz
dotnet-install:(B Adding to current process PATH: `/home/appveyor/.dotnet`. Note: This change will be visible only when sourcing script.
dotnet-install:(B Installation finished successfully.
dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.300
 Commit:    b2475c1295
Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.04
 OS Platform: Linux
 RID:         ubuntu.18.04-x64
 Base Path:   /usr/share/dotnet/sdk/3.1.300/
Host (useful for support):
  Version: 5.0.0-preview.3.20214.6
  Commit:  b037784658
.NET SDKs installed:
  1.1.14 [/usr/share/dotnet/sdk]
  2.1.202 [/usr/share/dotnet/sdk]
  2.1.806 [/usr/share/dotnet/sdk]
  2.2.402 [/usr/share/dotnet/sdk]
  3.0.103 [/usr/share/dotnet/sdk]
  3.1.300 [/usr/share/dotnet/sdk]
  5.0.100-preview.3.20216.6 [/usr/share/dotnet/sdk]
.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.18 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.18 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.4 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-preview.3.20215.14 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.1.13 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.9 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.18 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.4 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-preview.3.20214.6 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

OKAY - so notice how I think it installed it to some weird/not default directory? well, I tried changing the command with specifying the directory to install into:

Command: curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --runtime dotnet --version 3.1.6 --install-dir /usr/share/dotnet

and now I get the following error:

curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --runtime dotnet --version 3.1.6 --install-dir /usr/share/dotnet
dotnet_install: Warning: Unable to locate zlib. Probable prerequisite missing; install zlib.(B
dotnet-install:(B Downloading link: https://dotnetcli.azureedge.net/dotnet/Runtime/3.1.6/dotnet-runtime-3.1.6-linux-x64.tar.gz
dotnet-install:(B Extracting zip from https://dotnetcli.azureedge.net/dotnet/Runtime/3.1.6/dotnet-runtime-3.1.6-linux-x64.tar.gz
cp: cannot create directory '/usr/share/dotnet/host/fxr/3.1.6/': Permission denied
Command exited with code 1
Build failed

So - i'm stuck. can anyone help please?

(of course, this could apply to any dotnet sdk version, I assume)

  1. Support Staff 1 Posted by Feodor Fitsner on 24 Aug, 2020 02:13 AM

    Feodor Fitsner's Avatar

    Hi Pure,

    You have to use sudo to write to /usr/share/dotnet folder. We use the following script to install the latest .NET Core on Linux:

    environment:
      CORE_SDK_LINUX_URL: https://download.visualstudio.microsoft.com/download/pr/4f9b8a64-5e09-456c-a087-527cfc8b4cd2/15e14ec06eab947432de139f172f7a98/dotnet-sdk-3.1.401-linux-x64.tar.gz
    
    install:
    - sh: wget -O dotnet-sdk.tar.gz ${CORE_SDK_LINUX_URL}
    - sh: sudo tar zxf dotnet-sdk.tar.gz -C /usr/share/dotnet
    - dotnet --version
    

    You can take the exact URL of distro on this page: https://dotnet.microsoft.com/download/dotnet-core/3.1 (Binaries -> x64).

  2. 2 Posted by Pure Krome on 24 Aug, 2020 04:33 AM

    Pure Krome's Avatar

    hi @feodor - thanks heaps for the sample scripts. Your scripts work - awesome.

    I went back and tried to use the microsoft sh scripts and they also work when I added sudo in:

    • dotnet runtime only: curl -sSL https://dot.net/v1/dotnet-install.sh | sudo bash /dev/stdin --runtime dotnet --version 3.1.6
    • aspnetcore: curl -sSL https://dot.net/v1/dotnet-install.sh | sudo bash /dev/stdin --runtime aspnetcore --version 3.1.6

    cheers!

  3. Pure Krome closed this discussion on 24 Aug, 2020 04:35 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac