DEV Community

loading...

Microsoft created some dotnet installer scripts (official)

Miles
Updated on ・2 min read

Installing dotnet core is getting easier. There are two scripts that Microsoft offer to install on Windows or Unix.

https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script

https://dot.net/v1/dotnet-install.sh for Linux/MacOS

https://dot.net/v1/dotnet-install.ps1 for Windows

These scripts have a lot of parameters you can use such as:

  • -Version if you need a previous version
  • -InstallDir if you have a specific location you need to install on
  • -Dry-Run if you want to simulate the installtion without any files changing
  • -Architecture if you want to run x86 on a x64 machine

The official documentation shows all the available parameters and some examples of how to use

If you want to run quickly you could run

# In Windows
&powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) <additional install-script args>"
Enter fullscreen mode Exit fullscreen mode
# In Linux
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin <additional install-script args>
Enter fullscreen mode Exit fullscreen mode

Or if you want to install a specific version (assuming you have downloaded the script file first)

# In Windows
./dotnet-install.ps1 -Runtime dotnet -Version 3.0.0
Enter fullscreen mode Exit fullscreen mode
# In Linux
./dotnet-install.ps1 -Runtime dotnet -Version 3.0.0
Enter fullscreen mode Exit fullscreen mode

Of course there are some caveats. https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script#script-behavior. Some dependencies need to be installed and there is a lot of default behaviour so check out the parameters list if you have any special requirements https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script#options.

Discussion (0)