Cách tạo Solution trong Visual Studio

Bạn cần biết về cách tổ chức các project trong visual studio. Hình bên dưới là cấu trúc solution của mình.

Nhìn vào cửa sổ Solution Explorer, bạn sẽ thấy 3 đối tượng chính:
1. Project: Mỗi chương trình là một project, khi biên dịch 1 project sẽ tạo ra 1 file exe. Như hình thì có tổng cộng 13 project đại diện cho 13 bài mình đang học.
2. Solution: Là một nhóm các project [trong hình là C++ Console]. Khi tạo một project đầu tiên, Visual Studio sẽ hỏi thêm tạo một solution.
3. Files: Trong mỗi project có thể thêm các file .cpp, .h… vào, như ví dụ project 8 đang mở của mình chỉ có một file main.cpp.

Mình thường làm thế này. Đầu tiên tạo một new project trước. Lúc này VS sẽ hỏi thêm tên solution [vì chưa có solution nào để chứa nó].

Đối với các project tiếp theo, mình chỉ cần mở solution [file .sln] trước đó, trong cửa sổ Solution Explorer, chuột phải vào solution và chọn Add > New Project… > Chọn loại project [nên chọn Empty project]. Sau đó là active project, chọn chuột phải vào project mới tạo > Set at Startup project > Project được chọn sẽ được in đậm.

Để thêm các file vào project hiện tại, nhấn Ctrl+Shift+A như bình thường.

  • Bài viết
  • 11/25/2021
  • 4 phút để đọc

In this article, we'll show you how to quickly create a new project in Visual Studio from a template.

There are multiple ways to create a new project in Visual Studio 2017. On the Start page, you can type in the name of a project template in the Search project templates box or select the Create new project link to open the New Project dialog box. Aside from the Start page, you can also select File > New > Project on the menu bar or select the New Project button on the toolbar.

Select a template type in Visual Studio 2017

In the New Project dialog box, available project templates appear in a list under the Templates category. Templates are organized by programming language and project type, such as Visual C#, JavaScript, and Azure Data Lake.

Show the list of templates for the programming language you want to use by selecting the triangle next to the language name and then choosing a project category [such as Windows Desktop].

The following image shows the project templates available for Visual C# .NET Core projects:

Configure your project in Visual Studio 2017

Enter a name for the new project in the Name box. You can save the project in the default location on your computer or select the Browse button to find another location. You can also select a solution name or add the new project to a Git repository [by selecting Add to Source Control].

Select OK to create the solution and project.

There are multiple ways to create a new project in Visual Studio. When you first open Visual Studio, the start window appears, and from there, you can select Create a new project.

If the Visual Studio development environment is already open, you can create a new project by choosing File > New > Project on the menu bar. You can also select the New Project button on the toolbar, or press Ctrl+Shift+N.

There are multiple ways to create a new project in Visual Studio. When you first open Visual Studio, the start window appears, and from there, you can select Create a new project.

If the Visual Studio development environment is already open, you can create a new project by choosing File > New > Project on the menu bar. You can also select the New Project button on the toolbar, or press Ctrl+Shift+N.

On the Create a new project dialog, a list of your recently selected templates appears on the left. The templates are sorted by most recently used.

If you're not selecting from the recently used templates, you can filter all available project templates by Language [for example, C# or C++], Platform [for example, Windows or Azure], and Project type [for example, Desktop or Web]. You can also enter search text into the search box to further filter the templates, for example, asp.net.

The tags that appear under each template correspond to the three dropdown filters [Language, platform, and project type].

Tip

If you don't see the template you're looking for, you might be missing a workload for Visual Studio. To install additional workloads, for example, Azure Development or Mobile Development with .NET, select the Install more tools and features link to open Visual Studio Installer. From there, select the workloads you want to install, and then select Modify. After that, additional project templates will be available to choose from.

Select a template and then select Next.

The tags that appear under each template correspond to the three dropdown filters [Language, platform, and project type].

Tip

If you don't see the template you're looking for, you might be missing a workload for Visual Studio. To install additional workloads, for example, Azure Development or Mobile Development with .NET, select the Install more tools and features link to open Visual Studio Installer. From there, select the workloads you want to install, and then select Modify. After that, additional project templates will be available to choose from.

Select a template and then select Next.

The Configure your new project dialog has options to name your project [and solution], select a disk location, and select a Framework version [if applicable to the template you chose].

Note

If you create a new project when you already have a project or solution open in Visual Studio, an extra configuration option is available. You can choose to create a new solution or add the new project to the solution that's already open.

Select Create to create the new project.

The Configure your new project dialog has options to name your project [and solution], select a disk location, and more.

The Additional information dialog includes options to select a Framework version, an authentication type, and more.

Select Create to create the new project.

Add additional projects to a solution

If you want to add an additional project to a solution, right-click the solution node in Solution Explorer and then select Add > New Project.

See also

Video liên quan

Chủ Đề