Setting Up Your .NET Development Environment
This guide will walk you through the process of installing and configuring the necessary tools to start developing with .NET.
1. Download the .NET SDK
The .NET SDK (Software Development Kit) includes the .NET runtime, the C# compiler, and other tools needed to build .NET applications.
Visit the official .NET Download page to get the latest recommended version.
- Choose the appropriate installer for your operating system (Windows, macOS, Linux).
- We recommend installing the latest LTS (Long-Term Support) or STS (Standard Term Support) version based on your project needs.
2. Install the .NET SDK
Windows:
- Run the downloaded installer (.exe file).
- Follow the on-screen prompts. Accept the license terms and choose the installation location (default is usually fine).
- The installer will guide you through the process. It's recommended to install the "Desktop development with .NET" workload if prompted, which includes Visual Studio Build Tools.
- Restart your computer after the installation is complete.
macOS:
- Run the downloaded installer (.pkg file).
- Follow the on-screen prompts.
- The installer will handle placing the SDK in the correct directories.
- Open a new Terminal window to ensure the PATH environment variable is updated.
Linux:
Installation methods vary slightly by distribution. Here's a common approach for Debian/Ubuntu-based systems:
- Open your terminal.
- Add the Microsoft package repository:
wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb rm packages-microsoft-prod.deb
- Update your package list:
sudo apt update
- Install the .NET SDK (e.g., for .NET 8):
sudo apt install dotnet-sdk-8.0
(Replace `8.0` with the desired version) - Verify the installation in a new terminal session.
For other Linux distributions, please refer to the official Linux installation guide.
3. Verify the Installation
After installation, open a new command prompt or terminal window and run the following command:
dotnet --version
This should output the version of the .NET SDK you just installed. If you encounter errors, ensure your PATH environment variable is correctly set or try restarting your machine.
4. Choose a Code Editor or IDE
You'll need an editor to write your code. Here are some popular choices:
- Visual Studio: A full-featured Integrated Development Environment (IDE) for Windows and Mac. Excellent for large projects and professional development. Download from Visual Studio Downloads.
- Visual Studio Code (VS Code): A lightweight, free, and highly extensible code editor available for Windows, macOS, and Linux. Install the C# extension for the best .NET experience. Download from Visual Studio Code.
- JetBrains Rider: A powerful cross-platform .NET IDE known for its intelligent code completion and refactoring tools. Available for Windows, macOS, and Linux. Visit JetBrains Rider.
5. Create Your First .NET Application
Open your terminal or command prompt and navigate to a directory where you want to create your project. Then, run:
dotnet new console -o MyFirstApp cd MyFirstApp dotnet run
This will create a new console application named "MyFirstApp", change into its directory, and then build and run it, displaying "Hello, World!" on your console.