Windows

  1. Download Visual Studio:

    • Download and install Visual Studio which includes C# support. Choose the workload for .NET development during installation.
  2. Alternative: .NET Core SDK:

    • Download and install .NET Core SDK which provides a command-line interface for C# development.
  3. Verify Installation:

    • Open Command Prompt and type:
  dotnet --version
  

Linux (CentOS/RHEL using yum)

  1. Install .NET SDK:
  • Register Microsoft key and feed:
  sudo rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm
  
  • Install SDK:
  sudo yum install -y dotnet-sdk-5.0
  
  1. Verify Installation:
  • Open Terminal and type:
  dotnet --version
  

Linux (Ubuntu/Debian using apt)

  1. Install .NET SDK:
  • Register Microsoft key and feed:
  wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
  
  • Install SDK:
  sudo apt-get install -y dotnet-sdk-5.0
  
  1. Verify Installation:
  • Open Terminal and type:
  dotnet --version
  

macOS

  • Install .NET SDK:

  • Install Homebrew if not already installed:

  /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  
  • Install SDK:
  brew install dotnet-sdk
  
  1. Verify Installation:
  • Open Terminal and type:
  dotnet --version
  

Visual Studio Code Setup

  1. Install the C# Dev Kit extension.
  2. Install .NET SDK 8 LTS from dotnet.microsoft.com.
  3. Verify: dotnet --version should show 8.x.
  4. Create a project: dotnet new console -n HelloApp.

Windows with winget

  winget install Microsoft.DotNet.SDK.8
dotnet --version
  

Updating the SDK

  dotnet --list-sdks
# Install newer SDK alongside older versions — global.json pins project version
  

Create global.json to pin SDK for a project:

  {
  "sdk": {
    "version": "8.0.100",
    "rollForward": "latestFeature"
  }
}
  

Docker Development

  FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY . .
RUN dotnet publish -c Release -o /app

FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["dotnet", "MyApp.dll"]
  

Troubleshooting

Issue Solution
dotnet not found Restart terminal; verify PATH
SDK version mismatch Check global.json
Restore failures Clear NuGet cache: dotnet nuget locals all --clear