Skip to main content

Command Palette

Search for a command to run...

Installing Dot Net SDK

Published
4 min read
M

Mohamad's interest is in Programming (Mobile, Web, Database and Machine Learning). He is studying at the Center For Artificial Intelligence Technology (CAIT), Universiti Kebangsaan Malaysia (UKM).

[1] Using installer

[2] Installation via Chocolatey

If you haven’t got Chocolatey, run the following command in PowerShell 7:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

Search available packages

choco search dotnet-sdk

Example:

PS C:\Users\User> choco search dotnet-sdk
Chocolatey v2.0.0
chocolatey-dotnetfx.extension 1.0.1
Dogtail.DotNet3.5SP1 11.2.13230.2
dotnet 9.0.4 [Approved]
dotnet.script 1.3.1 [Approved]
dotnet1.1 1.1.0 [Approved] Downloads cached for licensed users - Possibly broken for FOSS users (due to original download location changes by vendor)
DotNet3.5 3.5.20241212 [Approved]
DotNet4.0 4.0.30319.20141222 [Approved]
DotNet4.5 4.5.20120822 [Approved]
DotNet4.5.1 4.5.1.20140606 [Approved]
DotNet4.5.2 4.5.2.20140902 [Approved]
DotNet4.6 4.6.81.20150925 [Approved]
DotNet4.6.1 4.6.1055.20170308 [Approved]
DotNet4.6.1-DevPack 4.6.1055 [Approved]
dotnet4.6.2 4.6.1590.20190822 [Approved]
DotNet-4.6.2 4.6.1586.2 [Approved]
dotnet4.6.2-deu 4.6.1590.20190918 [Approved] Downloads cached for licensed users
DotNet4.6-TargetPack 4.6.81.20150925 [Approved]
dotnet4.7 4.7.2053.20190226 [Approved]
dotnet4.7.1 4.7.2558.20190226 [Approved]
dotnet4.7.2 4.7.2.20210903 [Approved]
dotnet4.7.2-deu 4.7.3062 [Approved]
dotnet-5.0-aspnetruntime 5.0.17 [Approved]
dotnet-5.0-desktopruntime 5.0.17 [Approved]
dotnet-5.0-runtime 5.0.17 [Approved]
dotnet-5.0-sdk 5.0.408 [Approved]
dotnet-5.0-sdk-1xx 5.0.104 [Approved] Downloads cached for licensed users
dotnet-5.0-sdk-2xx 5.0.214 [Approved] Downloads cached for licensed users
dotnet-5.0-sdk-3xx 5.0.303 [Approved] Downloads cached for licensed users
dotnet-5.0-sdk-4xx 5.0.408 [Approved] Downloads cached for licensed users
dotnet-5.0-windowshosting 5.0.17 [Approved]
dotnet5-desktop-runtime 5.0.6 [Approved]
dotnet-6.0-aspnetruntime 6.0.36 [Approved]
dotnet-6.0-desktopruntime 6.0.36 [Approved]
dotnet-6.0-runtime 6.0.36 [Approved]
dotnet-6.0-sdk 6.0.428 [Approved]
dotnet-6.0-sdk-1xx 6.0.136 [Approved] Downloads cached for licensed users
dotnet-6.0-sdk-2xx 6.0.203 [Approved] Downloads cached for licensed users
dotnet-6.0-sdk-3xx 6.0.321 [Approved] Downloads cached for licensed users
dotnet-6.0-sdk-4xx 6.0.428 [Approved] Downloads cached for licensed users
dotnet-6.0-windowshosting 6.0.36 [Approved]
dotnet-7.0-aspnetruntime 7.0.20 [Approved]
dotnet-7.0-desktopruntime 7.0.20 [Approved]
dotnet-7.0-runtime 7.0.20 [Approved]
dotnet-7.0-sdk 7.0.410 [Approved]
dotnet-7.0-sdk-1xx 7.0.120 [Approved] Downloads cached for licensed users
dotnet-7.0-sdk-2xx 7.0.203 [Approved] Downloads cached for licensed users
dotnet-7.0-sdk-3xx 7.0.317 [Approved] Downloads cached for licensed users
dotnet-7.0-sdk-4xx 7.0.410 [Approved] Downloads cached for licensed users
dotnet-7.0-windowshosting 7.0.20 [Approved]
dotnet-8.0-aspnetruntime 8.0.15 [Approved]
dotnet-8.0-desktopruntime 8.0.15 [Approved]
dotnet-8.0-runtime 8.0.15 [Approved]
dotnet-8.0-sdk 8.0.408 [Approved]
dotnet-8.0-sdk-1xx 8.0.115 [Approved] Downloads cached for licensed users
dotnet-8.0-sdk-2xx 8.0.206 [Approved] Downloads cached for licensed users
dotnet-8.0-sdk-3xx 8.0.311 [Approved] Downloads cached for licensed users
dotnet-8.0-sdk-4xx 8.0.408 [Approved] Downloads cached for licensed users
dotnet-8.0-windowshosting 8.0.15 [Approved]

Install dotnet via chocolatey:

choco install dotnet-8.0-sdk

Example:

PS C:\Users\User> choco install dotnet-8.0-sdk
Chocolatey v2.0.0
Installing the following packages:
dotnet-8.0-sdk
By installing, you accept licenses for the packages.

dotnet-8.0-sdk-4xx v8.0.408 [Approved]
dotnet-8.0-sdk-4xx package files install completed. Performing other installation steps.
The package dotnet-8.0-sdk-4xx wants to run 'ChocolateyInstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint): A

File appears to be downloaded already. Verifying with package checksum to determine if it needs to be redownloaded.
Hashes match.
Hashes match.
Installing dotnet-8.0-sdk-4xx...
dotnet-8.0-sdk-4xx has been installed.
  dotnet-8.0-sdk-4xx may be able to be automatically uninstalled.
Environment Vars (like PATH) have changed. Close/reopen your shell to
 see the changes (or in powershell/cmd.exe just type `refreshenv`).
 The install of dotnet-8.0-sdk-4xx was successful.
  Software installed as 'exe', install location is likely default.
Progress: Downloading dotnet-8.0-sdk 8.0.408... 100%

dotnet-8.0-sdk v8.0.408 [Approved]
dotnet-8.0-sdk package files install completed. Performing other installation steps.
 The install of dotnet-8.0-sdk was successful.
  Software installed to 'C:\ProgramData\chocolatey\lib\dotnet-8.0-sdk'

Chocolatey installed 2/2 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Open a new PowerShell 7 window, test dotnet:

PS C:\Windows\System32> cd ~
PS C:\Users\User> dotnet

Usage: dotnet [options]
Usage: dotnet [path-to-application]

Options:
  -h|--help         Display help.
  --info            Display .NET information.
  --list-sdks       Display the installed SDKs.
  --list-runtimes   Display the installed runtimes.

path-to-application:
  The path to an application .dll file to execute.
PS C:\Users\User>

Getting Started with ASP.NET Core

(https://learn.microsoft.com/en-us/aspnet/core/getting-started/?view=aspnetcore-8.0)

Make a tutorial root folder

mkdir mydotnet
cd mydotnet

Create a dotnet project

dotnet new webapp --output aspnetcoreapp --no-https

Example:

PS C:\Users\User> cd mydotnet
PS C:\Users\User\mydotnet> dotnet new webapp --output aspnetcoreapp --no-https

Welcome to .NET 8.0!
---------------------
SDK Version: 8.0.408

Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate, run 'dotnet dev-certs https --trust'
Learn about HTTPS: https://aka.ms/dotnet-https

----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
The template "ASP.NET Core Web App (Razor Pages)" was created successfully.
This template contains technologies from parties other than Microsoft, see https://aka.ms/aspnetcore/8.0-third-party-notices for details.

Processing post-creation actions...
Restoring C:\Users\User\mydotnet\aspnetcoreapp\aspnetcoreapp.csproj:
  Determining projects to restore...
  Restored C:\Users\User\mydotnet\aspnetcoreapp\aspnetcoreapp.csproj (in 46 ms).
Restore succeeded.

Run the app:

cd aspnetcoreapp
dotnet run

Example:

PS C:\Users\User\mydotnet> cd aspnetcoreapp
PS C:\Users\User\mydotnet\aspnetcoreapp> dotnet run
Building...
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5150
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\Users\User\mydotnet\aspnetcoreapp

Web example:

Folder structure:

Installing Dot Net SDK