Visual Studio 中的部署簡介First look at deployment in Visual Studio

透過部署應用程式、服務或元件,就可以將它散發到其他電腦、裝置、伺服器或雲端上進行安裝。By deploying an application, service, or component, you distribute it for installation on other computers, devices, or servers, or in the cloud. 請在 Visual Studio 中針對您需要的部署類型選擇適當的方法。You choose the appropriate method in Visual Studio for the type of deployment that you need. (許多應用類型都支援此處未介紹的其他部署工具,如命令行部署。(Many app types support other deployment tools such as command line deployment that are not described here.)

請參閱快速入門和教學課程以取得逐步部署指示。See the Quickstarts and Tutorials for step-by-step deployment instructions. 如需部署選項的概觀,請參閱適合我的發行選項為何?For an overview of deployment options, see What publishing options are right for me?.

部署至本機資料夾Deploy to local folder

部署至本機資料夾通常用於測試,或是用來開始使用另一個工具進行最終部署的分段部署。Deployment to a local folder is typically used for testing, or to begin a staged deployment in which another tool is used for final deployment.

  • ASP.NETASP.NET CoreNode.jsPython 及 .NET Core:使用發行工具以部署至本機資料夾。ASP.NET, ASP.NET Core, Node.js, Python, and .NET Core: Use the Publish tool to deploy to a local folder. 確切的可用選項取決於您的應用程式類型。The exact options available depend on your app type. 在 [方案總管] 中,以滑鼠右鍵按一下專案,然後選擇 [發行]****In Solution Explorer, right-click your project and choose Publish. (如果以前未配置任何發佈配置檔,則必須單擊"創建新配置檔"。接下來,選擇 "資料夾"。(If you have not previously configured any publishing profiles, you must then click Create new profile.) Next, choose Folder. 如需詳細資訊,請參閱部署至本機資料夾For more information, see Deploy to a local folder.

    選擇 [發行]

  • Windows 傳統型:使用 ClickOnce 部署可以將 Windows 傳統型應用程式發行至資料夾。Windows desktop You can publish a Windows desktop application to a folder using ClickOnce deployment. 使用者只要按一下,就可以安裝應用程式。Users can then install the application with a single click. 如需詳細資訊,請參閱使用 ClickOnce 部署傳統型應用程式 (C# 和 Visual Basic)。For more information, see Deploy a desktop app using ClickOnce (C# and Visual Basic). 有關C++/CLI,請參閱使用 ClickOnce 部署本機應用,或者對於 C/C++,請參閱使用安裝程式部署本機應用For C++/CLI, see Deploy a native app using ClickOnce or, for C/C++, see Deploy a native app using a Setup project.

發佈至 AzurePublish to Azure

  • ASP.NET ,ASP.NET核心****、 PythonNode.js: 使用以下方法之一發布到 Azure 應用服務或 Azure 應用服務 Linux(使用容器)。ASP.NET, ASP.NET Core, Python, and Node.js: Publish to Azure App Service or Azure App Service Linux (using containers) using one of the following methods.

    • 針對連續 (或自動) 部署應用程式,使用 Azure DevOps 與 Azure PipelinesFor continuous (or automated) deployment of apps, use Azure DevOps with Azure Pipelines.

    • 針對一次 (或手動) 部署應用程式,請使用 Visual Studio 中的 [發行]**** 工具。For one-time (or manual) deployment of apps, use the Publish tool in Visual Studio.

    針對提供伺服器自訂組態的部署,您也可以使用 [發行]**** 工具將應用程式部署至 Azure 虛擬機器。For deployment that provides more customized configuration of the server, you can also use the Publish tool to deploy apps to an Azure Virtual Machine.

    若要使用 [發行]**** 工具,以滑鼠右鍵按一下 [方案總管] 中的專案,然後選擇 [發行]****。To use the Publish tool, right-click the project in Solution Explorer and choose Publish. (如果以前配置過任何發佈配置檔,則必須單擊"創建新配置檔"。在"發佈"對話框中,選擇應用服務Azure 虛擬機,然後按照配置步驟操作。(If you have previously configured any publishing profiles, you must then click Create new profile.) In the Publish dialog box, choose either App Service or Azure Virtual Machines, and then follow the configuration steps.

    選擇 Azure 應用服務Choose Azure App Service

    從 Visual Studio 2017 15.7 版開始,您可以將 ASP.NET Core 應用程式部署至適用於 Linux 的 App ServiceStarting in Visual Studio 2017 version 15.7, you can deploy ASP.NET Core apps to App Service for Linux.

    針對 Python 應用程式,另請參閱 Python - 發行至 Azure App ServiceFor Python apps, also see Python - Publishing to Azure App Service.

    如需快速簡介,請參閱發行至 Azure發行至 LinuxFor a quick introduction, see Publish to Azure and Publish to Linux. 此外,請參閱將 ASP.NET Core 應用程式發行至 AzureAlso, see Publish an ASP.NET Core app to Azure. 如需使用 Git 進行部署,請參閱使用 Git 將 ASP.NET Core 持續部署至 AzureFor deployment using Git, see Continuous deployment of ASP.NET Core to Azure with Git.

    如需將發行設定檔從 Azure App Service 匯入至 Visual Studio 的資訊,請參閱匯入發行設定並部署至 AzureFor information on importing a publish profile from Azure App Service to Visual Studio, see Import publish settings and deploy to Azure.

    注意

    如果您還沒有 Azure 帳戶,則可以在這裡註冊If you do not already have an Azure account, you can sign up here.

發行至 Web 或部署至網路共用Publish to Web or deploy to network share

  • ASP.NETASP.NET CoreNode.jsPython:您可以使用發行工具,利用 FTP 或 Web Deploy 部署至網站。ASP.NET, ASP.NET Core, Node.js, and Python: You can use the Publish tool to deploy to a website using FTP or Web Deploy. 如需詳細資訊,請參閱部署至網站For more information, see Deploy to a web site.

    在解決方案資源管理器中,右鍵單擊專案並選擇 「發布」。In Solution Explorer, right-click the project and choose Publish. (如果以前配置過任何發佈配置檔,則必須單擊"創建新配置檔"。在「發佈」工具中,選擇所需的選項,然後按照配置步驟操作。(If you have previously configured any publishing profiles, you must then click Create new profile.) In the Publish tool, choose the option you want and follow the configuration steps.

    選擇 [IIS、FTP 等等]。

    如需在 Visual Studio 中匯入發行設定檔的資訊,請參閱匯入發行設定並部署至 IISFor information on importing a publish profile in Visual Studio, see Import publish settings and deploy to IIS.

    您也可以使用許多其他方式來部署 ASP.NET 應用程式和服務。You can also deploy ASP.NET applications and services in a number of other ways. 如需詳細資訊,請參閱部署 ASP.NET Web 應用程式和服務For more information, see Deploying ASP.NET web applications and services.

  • Windows 傳統型:使用 ClickOnce 部署可以將 Windows 傳統型應用程式發行至 Web 伺服器或網路檔案共用。Windows desktop You can publish a Windows desktop application to a web server or a network file share using ClickOnce deployment. 使用者只要按一下,就可以安裝應用程式。Users can then install the application with a single click. 如需詳細資訊,請參閱使用 ClickOnce 部署傳統型應用程式 (C# 和 Visual Basic)。For more information, see Deploy a desktop app using ClickOnce (C# and Visual Basic). 有關C++/CLI,請參閱使用 ClickOnce 部署本機應用,或者對於 C/C++,請參閱使用安裝程式部署本機應用For C++/CLI, see Deploy a native app using ClickOnce or, for C/C++, see Deploy a native app using a Setup project.

發行至 Microsoft StorePublish to Microsoft Store

您可以從 Visual Studio 中建立應用程式套件,以部署至 Microsoft Store。From Visual Studio, you can create app packages for deployment to Microsoft Store.

將 .NET 套件部署到 NuGet.orgDeploy .NET packages to NuGet.org

若要將套件組合程式碼部署到包含 已編譯程式碼 (編譯為 DLL) 與取用這些套件之專案中需要之內容的 "packages",您可以使用 Visual Studio 來建立 NuGet 套件與 CLI 工具來發出最終部署命令。To deploy bundled code into "packages" that contain compiled code (as DLLs) along with other content needed in the projects that consume these packages, you can use Visual Studio to create the NuGet package and a CLI tool to issue the final deployment command.

部署至裝置 (UWP)Deploy to a device (UWP)

如果您要部署 UWP 應用程式以便在裝置上進行測試,請參閱在 Visual Studio 的遠端電腦上執行 UWP 應用程式If you are deploying a UWP app for testing on a device, see Run UWP apps on a remote machine in Visual Studio.

建立安裝程式套件 (Windows 桌面)Create an installer package (Windows desktop)

如果您需要比 ClickOnce 可提供的傳統型應用程式更複雜的安裝,您可以建立 Windows Installer 套件 (MSI 或 EXE 安裝檔案) 或自訂啟動載入器。If you require more a complex installation of a desktop application than ClickOnce can provide, you can create a Windows Installer package (MSI or EXE installation file) or a custom bootstrapper.

  • MSI 型安裝程式套件可以使用 WiX Toolset Extension 來建立。An MSI-based installer package can be created using the WiX Toolset Extension. 這是命令列工具組。This is a command-line toolset.

    針對 Visual Studio 2019,請取得 WiX Toolset Visual Studio 2019 Extension (英文)。For Visual Studio 2019, get the WiX Toolset Visual Studio 2019 Extension.

  • 可以使用 Flexera Software 的 InstallShield 來建立 MSI 或 EXE 安裝程式套件。An MSI or EXE installer package can be created using InstallShield from Flexera Software. InstallShield 可能會與 Visual Studio 2017 和更新版本 (不支援 Community Edition) 搭配使用。InstallShield may be used with Visual Studio 2017 and later versions (Community Edition not supported). 請注意,InstallShield Limited Edition 不再隨附於 Visual Studio,且 Visual Studio 2017 和更新版本不支援該版本;請洽詢 Flexera Software (英文) 以了解未來的供應狀況。Note that InstallShield Limited Edition is no longer included with Visual Studio and is not supported in Visual Studio 2017 and later versions; check with Flexera Software about future availability.

  • 可以使用安裝專案 (vdproj) 建立 MSI 或 EXE 安裝程式套件。An MSI or EXE installer package can be created using a Setup project (vdproj). 若要使用此選項,請安裝 Visual Studio 安裝程式專案擴充功能 (英文)。To use this option, install the Visual Studio Installer Projects extension.

  • 您也可以藉由設定泛型安裝程式 (稱為啟動載入器) 來安裝傳統型應用程式的必要條件元件。You can also install prerequisite components for desktop applications by configuring a generic installer, which is known as a bootstrapper. 如需詳細資訊,請參閱應用程式部署必要條件For more information, see Application Deployment Prerequisites.

部署至測試實驗室Deploy to test lab

透過將應用程式部署至虛擬環境,即可啟用更複雜的開發和測試。You can enable more sophisticated development and testing by deploying your applications into virtual environments. 如需詳細資訊,請參閱在實驗室環境中測試For more information, see Test on a lab environment.

連續部署Continuous deployment

您可以使用 Azure Pipelines 來啟用應用程式的持續部署。You can use Azure Pipelines to enable continuous deployment of your app. 如需詳細資訊,請參閱 Azure Pipelines部署至 AzureFor more information, see Azure Pipelines and Deploy to Azure.

部署 SQL 資料庫Deploy a SQL database

其他應用程式類型的部署Deployment for other app types

應用程式類型App type 部署情節Deployment Scenario 連結Link
Office 應用程式Office app 您可以從 Visual Studio 發行 Office 的增益集。You can publish an add-in for Office from Visual Studio. 部署和發行 Office 增益集Deploy and publish your Office add-in
WCF 或 OData 服務WCF or OData service 其他應用程式可以使用您部署至 Web 伺服器的 WCF RIA 服務。Other applications can use WCF RIA services that you deploy to a web server. 開發和部署 WCF Data ServicesDeveloping and deploying WCF Data Services
LightSwitchLightSwitch 從 Visual Studio 2017 開始就不再支援 LightSwitch,但仍然能夠從 Visual Studio 2015 和更早版本加以部署。LightSwitch is no longer supported starting in Visual Studio 2017, but can still be deployed from Visual Studio 2015 and earlier. 部署 LightSwitch 應用程式Deploying LightSwitch Applications

後續步驟Next steps

在本教學課程中,您已快速瀏覽過不同應用程式的部署選項。In this tutorial, you took a quick look at deployment options for different applications.