Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Microsoft Autogen Dotnet Install Script

From Leeroopedia
Knowledge Sources
Domains Installation, DotNet, Shell_Scripting
Last Updated 2026-02-11 17:00 GMT

Overview

A comprehensive Bash script for downloading and installing the .NET SDK and runtime on Unix-like systems (Linux, macOS, FreeBSD).

Description

This is the official .NET installation script from Microsoft, included in the AutoGen repository for .NET development support. It provides a robust, cross-platform solution for installing specific versions of .NET SDK, .NET Runtime, or ASP.NET Core Runtime. The script handles OS detection (including special cases like Alpine Linux musl, RHEL 6), architecture detection (x64, arm, arm64, s390x, ppc64le, loongarch64, riscv64), version resolution from channels or specific version strings, download and validation of installation packages, and extraction to specified directories. It includes extensive error handling, verbose logging options, and support for quality channels (daily, preview, GA).

Usage

Use this script when you need to:

  • Install .NET SDK or runtime in CI/CD pipelines
  • Set up development environments without package managers
  • Install specific .NET versions for compatibility
  • Install .NET on systems without official package manager support
  • Automate .NET installation across multiple platforms

Code Reference

Source Location

Signature

#!/usr/bin/env bash
# .NET SDK/Runtime Installation Script
# Copyright (c) .NET Foundation and contributors

# Core Functions:
get_current_os_name()           # Detect OS (linux/osx/freebsd/linux-musl)
get_machine_architecture()      # Detect architecture (x64/arm/arm64/etc)
get_normalized_architecture()   # Normalize architecture names
is_arm64_supported()            # Check if version supports ARM64
get_normalized_os()             # Normalize OS names
get_normalized_quality()        # Normalize quality (daily/preview/ga)
get_normalized_channel()        # Normalize channel (LTS/STS)
get_normalized_product()        # Normalize product (sdk/runtime/aspnetcore)
validate_remote_local_file_sizes() # Verify download integrity
download()                      # Download files with curl or wget
extract()                       # Extract tar.gz archives
install_dotnet()                # Main installation logic

Import

# Script uses standard Unix tools:
# - curl or wget (for downloads)
# - tar (for extraction)
# - uname (for OS/arch detection)
# - tput (for colored output)
# - ldd (for musl detection)

# Script requires bash and sets strict error handling:
set -e          # Exit on error
set -u          # Exit on undefined variable
set -o pipefail # Fail on pipe errors

I/O Contract

Inputs

Name Type Required Description
--channel string No Release channel (LTS, STS, or version like 8.0)
--version string No Specific version or 'latest'
--quality string No Build quality (daily, preview, ga)
--install-dir path No Installation directory (default: $HOME/.dotnet)
--architecture string No Target architecture (x64, arm, arm64, etc.)
--runtime string No Runtime type (dotnet, aspnetcore) - installs runtime instead of SDK
--os string No Override OS detection (osx, linux, freebsd, rhel.6, linux-musl)
--dry-run flag No Display download URL without installing
--no-path flag No Don't add to PATH
--verbose flag No Enable verbose logging
--azure-feed url No Custom Azure feed URL
--uncached-feed url No Custom uncached feed URL
--feed-credential string No Feed authentication token
--runtime-id string No Specific runtime identifier
--skip-non-versioned-files flag No Skip copying non-versioned files
--no-cdn flag No Disable CDN usage
--jsonfile path No Path to JSON file with installation parameters

Outputs

Name Type Description
Exit Code integer 0 on success, non-zero on failure
Installed Files directory .NET SDK/runtime files in install directory
Console Output text Installation progress and status messages
Error Messages text Detailed error information on stderr
Environment Variables suggestion PATH update suggestions (if --no-path used)

Usage Examples

Install Latest SDK

# Install latest stable .NET SDK to default location (~/.dotnet):
./dotnet-install.sh

# Install to custom directory:
./dotnet-install.sh --install-dir /opt/dotnet

Install Specific Version

# Install .NET 8.0 SDK:
./dotnet-install.sh --channel 8.0

# Install exact version:
./dotnet-install.sh --version 8.0.303

# Install latest version from channel:
./dotnet-install.sh --channel 8.0 --version latest

Install Runtime Only

# Install .NET Runtime (not full SDK):
./dotnet-install.sh --runtime dotnet --channel 8.0

# Install ASP.NET Core Runtime:
./dotnet-install.sh --runtime aspnetcore --channel 8.0

Architecture-Specific Installation

# Install ARM64 SDK on Apple Silicon Mac:
./dotnet-install.sh --architecture arm64 --channel 8.0

# Install x64 SDK (for Rosetta emulation):
./dotnet-install.sh --architecture x64 --channel 8.0

Preview/Daily Builds

# Install preview builds:
./dotnet-install.sh --channel 9.0 --quality preview

# Install daily builds (latest nightly):
./dotnet-install.sh --channel 9.0 --quality daily

Dry Run Mode

# Display download URL without installing:
./dotnet-install.sh --channel 8.0 --dry-run

# Verbose dry run for debugging:
./dotnet-install.sh --channel 8.0 --dry-run --verbose

CI/CD Usage

# Typical CI installation:
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin \
  --channel 8.0 \
  --install-dir ./dotnet \
  --no-path

# Add to PATH:
export PATH="$PWD/dotnet:$PATH"
export DOTNET_ROOT="$PWD/dotnet"

Multiple Version Installation

# Install .NET 6, 8, and 9 side by side:
./dotnet-install.sh --channel 6.0 --install-dir ~/.dotnet
./dotnet-install.sh --channel 8.0 --install-dir ~/.dotnet
./dotnet-install.sh --channel 9.0 --install-dir ~/.dotnet

# All versions coexist in ~/.dotnet

Key Functions

OS Detection

The script detects the operating system using uname and /etc/os-release:

  • Darwin → osx
  • Linux → linux (or linux-musl for Alpine-based distros)
  • FreeBSD → freebsd
  • Special handling for RHEL 6 and musl-based distributions

Architecture Detection

Detects CPU architecture and normalizes names:

  • x86_64, amd64 → x64
  • armv7l → arm
  • aarch64, arm64 → arm64 (with 32-bit OS detection)
  • s390x, ppc64le, loongarch64, riscv64 → same
  • Default fallback: x64

ARM64 Compatibility

Special logic for Apple Silicon Macs:

  • Checks if .NET version supports ARM64 (6.0+)
  • Falls back to x64 with Rosetta emulation for older versions
  • Validates Rosetta is installed before attempting x64 installation

Download Logic

Prefers curl over wget with automatic fallback:

  • Validates required tools exist (check_min_reqs)
  • Supports custom feeds and authentication
  • Performs file size validation after download
  • Retries on failure with detailed error messages

Version Resolution

Resolves versions from channels:

  • Channel → Latest patch version (e.g., 8.0 → 8.0.303)
  • LTS → Long-term support channel
  • STS → Standard-term support channel
  • latest → Most recent build from channel

Platform Support

Operating Systems

  • Linux (glibc-based distributions)
  • Linux (musl-based: Alpine)
  • macOS (Intel and Apple Silicon)
  • FreeBSD
  • RHEL 6 (legacy support)

Architectures

  • x64 (AMD64/Intel 64-bit)
  • arm (32-bit ARM)
  • arm64 (64-bit ARM/AArch64)
  • s390x (IBM Z)
  • ppc64le (PowerPC 64-bit Little Endian)
  • loongarch64 (LoongArch)
  • riscv64 (RISC-V 64-bit)

Error Handling

The script includes comprehensive error handling:

  • Validates prerequisites (curl/wget)
  • Checks architecture support
  • Verifies download integrity
  • Validates extracted files exist
  • Provides colored error messages with context
  • Suggests fixes for common issues

Common Errors

  • curl/wget missing → Install required download tool
  • Unsupported architecture → Check if .NET supports your platform
  • Version not found → Verify channel and version exist
  • Download failed → Check network and feed URLs
  • Extraction failed → Check disk space and permissions

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment