在 Visual Studio 中创建新项目

本文将介绍如何根据模板在 Visual Studio 中快速创建新项目。

打开“创建新项目”对话框

可通过多种方式在 Visual Studio 中创建新项目。 首次打开 Visual Studio 时,将显示“启动”窗口,通过此窗口可选择“创建新项目”。

Screenshot of the 'Create a new project' dialog from the start window in Visual Studio 2019

如果已打开 Visual Studio 开发环境,在菜单栏上选择“文件”>“新建”>“项目” 。 也可以选择工具栏上的“新建项目”按钮,或按 Ctrl+Shift+N 。

Screenshot of the New Project button in Visual Studio 2019.

打开“创建新项目”对话框

可通过多种方式在 Visual Studio 中创建新项目。 首次打开 Visual Studio 时,将显示“启动”窗口,通过此窗口可选择“创建新项目”。

Screenshot of the 'Create a new project' dialog from the start window in Visual Studio 2022.

如果已打开 Visual Studio 开发环境,在菜单栏上选择“文件”>“新建”>“项目” 。 也可以选择工具栏上的“新建项目”按钮,或按 Ctrl+Shift+N 。

Screenshot of the New Project button in Visual Studio 2022.

选择一个模板类型

在“创建新项目”对话框中,最近选择的模板列表显示在左侧。 模板按“最近使用”排序

如果没有从最近使用的模板中进行选择,则可以按“语言”(如 C#或 C++)、“平台”(如 Windows 或 Azure)和“项目类型”(如桌面或 Web)筛选所有可用的项目模板。 还可在搜索框中输入搜索文本(如 asp.net)以进一步筛选模板,例如 asp.net

Screenshot of the project template filters in Visual Studio 2019.

每个模板下方显示的标记对应于三个下拉筛选器(语言、平台和项目类型)。

提示

如果没有看到要查找的模板,则可能是丢失了 Visual Studio 的工作负载。 要安装其他工作负载(如 Azure 开发或使用 .NET 的移动开发),请选择“安装更多工具和功能”链接以打开 Visual Studio 安装程序 。 从中选择要安装的工作负载,然后选择“修改”。 之后,便可选择其他项目模板。

Screenshot of the 'Install more tools and features' link in Visual Studio 2019.

选择一个模板,然后选择“下一步”。

Screenshot of the project template filters in Visual Studio 2022.

每个模板下方显示的标记对应于三个下拉筛选器(语言、平台和项目类型)。

提示

如果没有看到要查找的模板,则可能是丢失了 Visual Studio 的工作负载。 要安装其他工作负载(如 Azure 开发或使用 .NET 的移动开发),请选择“安装更多工具和功能”链接以打开 Visual Studio 安装程序 。 从中选择要安装的工作负载,然后选择“修改”。 之后,便可选择其他项目模板。

Screenshot of the 'Install more tools and features' link in Visual Studio 2022.

选择一个模板,然后选择“下一步”。

配置新项目

“配置新项目”对话框中提供有关对项目(和解决方案)命名、选择磁盘位置和选择框架版本(如果适用于所选模板)的选项。

Screenshot of the 'Configure your new project' dialog in Visual Studio 2019.

注意

如果在 Visual Studio 中存在已打开的项目或解决方案时创建新项目,则可以使用额外的配置选项。 可选择创建新解决方案或将新项目添加到已打开的解决方案中。

Screenshot of the 'Create new solution' or 'Add to solution' dialog in Visual Studio 2019.

选择“创建”以创建新项目。

配置新项目

“配置新项目”对话框中提供有关对项目(和解决方案)命名、选择磁盘位置等的选项。

Screenshot showing the Configure your new project dialog in Visual Studio 2022 and the options to set, including the project name and project location.

“其他信息”对话框包含用于选择框架版本、身份验证类型等的选项。

Screenshot of the Additional Information dialog in Visual Studio 2022 showing the selected .NET Framework version for the new project.

选择“创建”以创建新项目。

向解决方案添加其他项目

若要向解决方案添加其他项目,请右键单击“解决方案资源管理器”中的解决方案节点,然后选择“添加”>“新建项目”。

提示

关于从头开始创建的项目和解决方案的示例,包括分步说明和示例代码,请参阅项目和解决方案简介