Build a .NET development environment on Windows

更新时间:
复制 MD 格式

This topic describes how to develop a .NET project by using Visual Studio Code (VS Code) on Windows.

Step 1: Install VS Code

  1. Visit the official website of VS Code and click Download for Windows to download the installation file.

  2. Double-click the downloaded file such as VSCodeUserSetup-x64-1.89.1.exe and use the installation wizard to install VS Code.

    Important

    In the Select Additional Tasks step, you must select Add to PATH (requires shell restart).

Step 2: Create a. NET project

  1. Open VS Code, and click Extensions in the left-side navigation pane or press Ctrl+Shift+X. In the EXTENSIONS panel, search for and install the following plug-ins:

    • C#: provides features such as IntelliSense, code navigation, debugging, code formatting, and refactoring. You can use the C# plug-in to manage .NET projects and NuGet packages. The C# plug-in seamlessly integrates .NET development processes and is a necessary tool for C# developers to improve coding efficiency.

    • .NET Install Tool: allows you to configure the C# development environment with ease and run the dotnet command to create, run, and build .NET core projects in VS Code. This simplifies the development process and improves the development efficiency.

  2. Create a console application: Select File > Open Folder to open a folder for your project. In the terminal, run the dotnet new console -n FirstDotnetProject command to create a new console application.

    PS D:\ide\dotnetprojects> dotnet new console -n FirstDotnetProject
    The template "Console App" was created successfully.
    Processing post-creation actions...
    Restoring D:\ide\dotnetprojects\FirstDotnetProject\FirstDotnetProject.csproj:
      Determining projects to restore...
      Restored D:\ide\dotnetprojects\FirstDotnetProject\FirstDotnetProject.csproj (in 68 ms).
    Restore succeeded.
    PS D:\ide\dotnetprojects>
  3. Run the project in the FirstDotnetProject folder and run the dotnet run command in VS Code. If Hello, World! is returned, the environment is built.

Step 3: Install dependencies

You can run the dotnet add package <package-name> command to install dependencies. For example, you can run the following command to install the ECS SDK dependency:

dotnet add package AlibabaCloud.SDK.Ecs20140526