CHAPTER 2: INSTALL THE TOOLS
What You Will Learn
• How to install the .NET 10 SDK
• How to install Visual Studio 2022 (version 17.14 or later)
• How to verify that your installation works
• How to create and run your first project using both the command line and Visual Studio
Getting Your Environment Ready
Before you can write code, you need to install the tools that let you compile and run your programs. C# and .NET are cross-platform, so you can develop on Windows, macOS, or Linux using the same SDK and project templates.
The installation process is quick, and once complete, you will be able to run a simple program from either the Visual Studio interface or the command line.
Step 1: Install the .NET 10 SDK
The .NET SDK (Software Development Kit) includes the compiler, templates, and command-line tools you will use throughout this book.
1. Visit https://dotnet.microsoft.com/download.
2. Choose .NET 10 (SDK) and download the correct installer for your operating system.
o On Windows, the installer will be a .exe file.
o On macOS, it will be a .pkg file.
o On Linux, most distributions include instructions for installing via a package manager.
3. Run the installer and follow the on-screen prompts. The default options are fine for almost everyone.
When finished, open a terminal or command prompt and type:
You should see a version number that begins with 10.. If you do, your SDK is ready to use.
Step 2: Install Visual Studio 2022
Visual Studio is Microsoft’s full-featured IDE for .NET development. This book uses Visual Studio 2022 version 17.14 or later.
1. Visit https://visualstudio.microsoft.com/downloads and select Visual Studio Community (the free edition).
2. Run the installer. When prompted to choose workloads, select:
o .NET desktop development
o ASP.NET and web development (optional, but useful later)
3. Continue through the installation. It may take a few minutes depending on your connection.
When Visual Studio opens, sign in with your Microsoft account (optional) and allow it to finish any updates.
Step 3: Verify the Installation
To confirm that everything works correctly:
1. Open Visual Studio.
2. Choose Create a new project.
3. Select Console App, make sure the framework says .NET 10.0, and click Create.
4. When the editor opens, press Ctrl+F5 (or Run Without Debugging).
You should see “Hello, World!” printed in a console window. If that works, your setup is complete. In later chapters, you will replace this simple message with more interesting logic and learn how each part of the program works.
Using the Command Line (Optional)
The .NET CLI is a powerful companion to Visual Studio. It lets you create, build, and run projects without an IDE.
Try this simple workflow:
1. Open a terminal or command prompt.
2. Run the following commands:
You now know two ways to start a program: from Visual Studio and from the command line. You can use either approach throughout this book.
Troubleshooting Tips
If dotnet --version does not show 10.x or if Visual Studio does not list .NET 10 as an option, close any open terminals and restart your computer. Sometimes your system path needs to refresh to recognize the SDK.
If problems continue, visit https://learn.microsoft.com/dotnet/core/install for detailed platform-specific instructions.
Key Terms
|
Term
|
Meaning
|
|
SDK
|
Software
Development Kit that contains compilers and templates for .NET projects.
|
|
IDE
|
Integrated
Development Environment, a program that provides an editor, debugger, and
tools for coding.
|
|
CLI
|
Command-Line
Interface used to run .NET commands directly from a terminal.
|
|
Template
|
A pre-configured
project setup used to create new applications quickly.
|