search
csharp

Fix: .NET SDK not found C# error

Complete guide to fix '.NET SDK not found' error in C#. Learn how to install, configure, and troubleshoot .NET SDK installations.

person By Gautam Sharma
calendar_today January 8, 2026
schedule 6 min read
C# .NET SDK Installation Error Fix Development Environment

The ’.NET SDK not found’ error occurs when the .NET SDK is not installed, not properly configured, or not accessible from the command line. This prevents building, running, and developing .NET applications.


How the Error Happens

This error typically occurs when:

  • .NET SDK is not installed on the system
  • PATH environment variable doesn’t include SDK location
  • Multiple SDK versions conflict
  • Installation was incomplete or corrupted
  • Wrong architecture SDK installed (x86 vs x64)
  • VS Code or IDE can’t locate the SDK

Solution 1: Install .NET SDK

# ✅ Download and install .NET SDK from official website
# Visit: https://dotnet.microsoft.com/download

# ✅ Or use package manager on Windows (Chocolatey)
choco install dotnet-sdk

# ✅ Or use package manager on macOS (Homebrew)
brew install --cask dotnet-sdk

# ✅ Or use package manager on Linux (Ubuntu/Debian)
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y dotnet-sdk-8.0
# ✅ PowerShell script to install .NET SDK
# Download and run the official installation script
Invoke-WebRequest -Uri https://dot.net/v1/dotnet-install.ps1 -OutFile dotnet-install.ps1
.\dotnet-install.ps1 -Channel LTS

Solution 2: Verify Installation and PATH

# ✅ Check if .NET SDK is installed and accessible
dotnet --version
dotnet --info

# ✅ If command not found, check PATH
echo %PATH%

# ✅ Typical .NET SDK installation paths:
# Windows: C:\Program Files\dotnet\
# macOS: /usr/local/share/dotnet/
# Linux: /usr/share/dotnet/
# ✅ PowerShell verification
$dotnetPath = Get-Command dotnet -ErrorAction SilentlyContinue
if ($dotnetPath) {
    Write-Host "dotnet found at: $($dotnetPath.Path)" -ForegroundColor Green
    Write-Host "Version: $(dotnet --version)" -ForegroundColor Green
} else {
    Write-Host "dotnet command not found in PATH" -ForegroundColor Red
}

Solution 3: Add .NET SDK to PATH

# ✅ Add to PATH manually (Windows)
# System Properties > Advanced > Environment Variables
# Add to PATH: C:\Program Files\dotnet\

# ✅ Or via command line (temporary)
set PATH=%PATH%;C:\Program Files\dotnet\

# ✅ Or via PowerShell (permanent)
$env:PATH += ";C:\Program Files\dotnet\"
[Environment]::SetEnvironmentVariable("PATH", $env:PATH + ";C:\Program Files\dotnet\", "Machine")
# ✅ Add to PATH on macOS/Linux
echo 'export PATH=$PATH:/usr/local/share/dotnet' >> ~/.bashrc
source ~/.bashrc

# ✅ Or for zsh users
echo 'export PATH=$PATH:/usr/local/share/dotnet' >> ~/.zshrc
source ~/.zshrc

Solution 4: Use Global.json for Version Selection

// ✅ Create global.json in project root
{
  "sdk": {
    "version": "8.0.100",
    "rollForward": "latestFeature"
  }
}
# ✅ Check available SDK versions
dotnet --list-sdks

# ✅ Check available runtimes
dotnet --list-runtimes

# ✅ Install specific SDK version
# Download from https://dotnet.microsoft.com/download/dotnet/8.0

Solution 5: Visual Studio Integration

# ✅ Install .NET development workload in Visual Studio
# Tools > Get Tools and Features > Individual Components
# Select ".NET SDK" and ".NET runtime"

# ✅ Or via Visual Studio Installer
# Modify > Individual Components > Check .NET SDK components
// ✅ For Visual Studio Code, ensure C# extension is installed
// Extensions > Search "C#" > Install "C# Dev Kit" by Microsoft

Solution 6: Troubleshoot Installation Issues

# ✅ Repair .NET installation (Windows)
# Run as Administrator
dotnet repair

# ✅ Or reinstall via official installer
# Download from https://dotnet.microsoft.com/download

# ✅ Clear NuGet cache if needed
dotnet nuget locals all --clear
# ✅ PowerShell script to verify installation
function Test-DotNetInstallation {
    try {
        $version = & dotnet --version 2>$null
        if ($version) {
            Write-Host "✅ .NET SDK version: $version" -ForegroundColor Green
            return $true
        } else {
            Write-Host "❌ .NET SDK not found" -ForegroundColor Red
            return $false
        }
    } catch {
        Write-Host "❌ .NET SDK not found: $($_.Exception.Message)" -ForegroundColor Red
        return $false
    }
}

Test-DotNetInstallation

Solution 7: Multiple SDK Versions Management

# ✅ List installed SDKs
dotnet --list-sdks

# ✅ List installed runtimes
dotnet --list-runtimes

# ✅ Use specific SDK version
dotnet new console --framework net8.0

# ✅ Create project with specific target
dotnet new webapi -f net6.0
// ✅ Global.json for specific project requirements
{
  "sdk": {
    "version": "6.0.400",
    "rollForward": "disable"
  },
  "tools": {
    "dotnet-ef": "6.0.0"
  }
}

Solution 8: IDE-Specific Configuration

// ✅ VS Code settings.json
{
    "omnisharp.dotnetPath": "C:\\Program Files\\dotnet",
    "csharp.suppressDotnetInstallWarning": false
}
<!-- ✅ For MSBuild projects, specify SDK version -->
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <RollForward>LatestMajor</RollForward>
  </PropertyGroup>
</Project>

Solution 9: Container Development

# ✅ Dockerfile with .NET SDK
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app
# Your application code here
# ✅ GitHub Actions workflow
name: Build and Test
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Setup .NET
      uses: actions/setup-dotnet@v3
      with:
        dotnet-version: 8.0.x
    - name: Restore dependencies
      run: dotnet restore
    - name: Build
      run: dotnet build --no-restore

Solution 10: Verify Installation Completeness

# ✅ Test basic .NET functionality
dotnet new console -n TestApp
cd TestApp
dotnet build
dotnet run

# ✅ Clean up test
cd ..
rm -rf TestApp
# ✅ PowerShell verification script
$checks = @(
    @{ Name = "dotnet command"; Test = { Get-Command dotnet -ErrorAction Stop } },
    @{ Name = "SDK version"; Test = { dotnet --version } },
    @{ Name = "Runtime info"; Test = { dotnet --info } },
    @{ Name = "New project"; Test = { 
        $tempDir = New-TemporaryFile | ForEach-Object { Remove-Item $_; New-Item -ItemType Directory -Path "$_.test" }
        Set-Location $tempDir
        dotnet new console --force
        $result = dotnet build
        Set-Location ..
        Remove-Item $tempDir -Recurse -Force
        return $result
    }}
)

foreach ($check in $checks) {
    try {
        $result = & $check.Test
        Write-Host "$($check.Name): Success" -ForegroundColor Green
    } catch {
        Write-Host "$($check.Name): Failed - $($_.Exception.Message)" -ForegroundColor Red
    }
}

Common Causes and Prevention

  1. Missing installation: Install .NET SDK from official source
  2. PATH issues: Ensure SDK directory is in system PATH
  3. Version conflicts: Use global.json for version pinning
  4. Architecture mismatch: Install correct architecture SDK
  5. Incomplete installation: Reinstall if corrupted
  6. IDE integration: Install proper extensions/tools

Best Practices

  • Always download .NET SDK from official Microsoft sources
  • Use global.json for consistent team development
  • Keep SDK updated to latest LTS version
  • Verify installation with basic project creation
  • Use version-specific installation for production
  • Document SDK requirements in project README
  • Test SDK availability in CI/CD pipelines
Gautam Sharma

About Gautam Sharma

Full-stack developer and tech blogger sharing coding tutorials and best practices

Related Articles

csharp

Fix: dotnet command not found error C#

Complete guide to fix 'dotnet command not found' error in C#. Learn how to install and configure .NET SDK for command line usage.

January 8, 2026
csharp

Fix: BadImageFormatException C# error

Complete guide to fix BadImageFormatException in C#. Learn how to resolve assembly architecture and format compatibility issues in .NET applications.

January 8, 2026
csharp

Fix: System.IO.IOException C# error

Complete guide to fix System.IO.IOException in C#. Learn how to handle file access, network, and I/O operation errors in .NET applications.

January 8, 2026