Visual Studio for Mac 中的專案和解決方案Projects and Solutions in Visual Studio for Mac

本文能提供 Visual Studio for Mac 中「專案」和「方案」的概念概觀。This article provides an overview of the project and solution concepts in Visual Studio for Mac.


本主題適用於 Visual Studio for Mac。This topic applies to Visual Studio for Mac. 針對 Windows 上的 Visual Studio,請參閱 Visual Studio 中的專案和方案For Visual Studio on Windows, see Projects and solutions in Visual Studio.


當您要在 Visual Studio for Mac 中建立新的應用程式和網站之類的內容時,您會以專案作為開始。When creating a new application, website, etc. in Visual Studio for Mac, you start with a project. 專案會包含編譯可執行檔、程式庫或網站所需的所有檔案 (原始程式碼、影像、資料檔案等等)。The project contains all the files required (source code, images, data files, etc.) that are needed to compile the executable, library, or website.

專案是由某個檔案所定義 (例如針對 C# 專案為 .csproj),其包含能定義檔案和資料夾階層的 XML、針對檔案和專案特定設定 (例如建置設定) 的路徑。A project is defined by a file (e.g., .csproj for C# projects) which contains xml that defines the file and folder hierarchy, paths to files and project-specific settings, such as build settings.

當 Visual Studio for Mac 載入專案時,方案視窗會使用專案檔來顯示專案中的檔案和資料夾。When a project is loaded by Visual Studio for Mac, the Solution Window uses the project file to display the files and folders in your project. 在編譯期間,MSBuild 會從專案檔讀取設定來建立可執行檔。During compilation, MSBuild reads the settings from the project file to create the executable.


「方案」是指能將一或多個相關專案分組在一起的容器。A solution is a container that groups together one or more related projects. 方案是由具有自己獨特格式的文字檔 (副檔名為 .sln) 所描述;它通常不適合手動編輯。Solutions are described by a text file (extension .sln) with its own unique format; it is not intended to be edited by hand.

在方案視窗中管理專案Managing Projects in the Solution Window

一旦建立或載入專案之後,您就可以使用 [方案] 視窗來查看和管理專案或方案,以及中包含的檔案。Once a project has been created or loaded, you can use the Solution Window to view and manage the project or solution and the files contained within. 下圖顯示包含兩個專案之 .NET Core 方案的 [方案] 視窗:The following illustration shows the Solution Window with a .NET Core solution that contains two projects:


您可以按兩下專案或方案名稱,或是以滑鼠右鍵按一下並選擇 [選項],來管理專案和方案的屬性。You can manage the properties of both projects and solutions by either double-clicking on the project or solution name, or by right-clicking and choosing Options.

管理方案和專案屬性一文提供這些選項的詳細資訊。More information on these options is provided in the Managing Solutions and Project Properties article.

請參閱See also