從您的程式碼建置 MSIX 套件Building an MSIX package from your code

如果您的傳統型應用程式正在開發中,建議您在建置環境中建置 MSIX 套件,而不是透過 MSIX 封裝工具產生安裝程式並執行。If your desktop application is in active development we recommend building an MSIX package in your build environment instead of generating an installer and running it through the MSIX Packaging Tool. 在 Visual Studio 2017 15.5 版和更新版本 (包括 Visual Studio 2019) 中,您可以使用 Windows 應用程式封裝專案,為應用程式產生 MSIX。In Visual Studio 2017 version 15.5 and later (including Visual Studio 2019) you can use the Windows Application Packaging Project to generate an MSIX for your application. 如果您不是在 Visual Studio 中進行開發,則有 MSIX 命令列工具,您可以將其整合至建置系統,以將應用程式二進位檔封裝為 MSIX。If you're not developing in Visual Studio there are MSIX command line tools you can integrate into your build system to package your application binaries as MSIX.

如果您正在開發 UWP 應用程式,則 Visual Studio 會預設為 MSIX,做為應用程式的封裝格式。If you're developing a UWP application, Visual Studio will default to MSIX as the packaging format for your application.

主題Topic 描述Description
封裝傳統型應用程式之前的須知事項What to know before packaging your desktop app MSIX 需求和已封裝傳統型應用程式執行階段行為的背景。Background on MSIX requirments and packaged desktop app runtime behavior. 在為您的傳統型應用程式建置 MSIX 套件之前,了解背景很有用。This is useful to know before building an MSIX package for your desktop application. 如果您要建置 UWP 應用程式,則可以略過本節。If you're building a UWP app you can skip this section.
在 Visual Studio 中封裝傳統型或 UWP 應用程式Packaging your desktop or UWP app in Visual Studio 本節討論如何將傳統型 (Windows Forms、WPF、Win32 等) 或 UWP 應用程式封裝為 Visual Studio 中的 MSIX。This section discusses how to package your desktop (Windows Forms, WPF, Win32 etc.) or UWP app as an MSIX in Visual Studio.
用於建置和部署 MSIX 的 CI/CD 管線CI/CD Pipelines for MSIX Builds and Deployments 本節討論如何在 Azure DevOps 中使用 CI/CD 管線將建置和部署工作流程自動化。This section discusses how to automate your build and deployment workflows using CI/CD pipelines in Azure DevOps.
從命令列封裝Packaging from the command line 本節討論如何使用命令列工具,將您的應用程式封裝為 MSIX。This section discusses how to package your app as an MSIX using command line tools.
擴充您的 MSIX 應用程式Extending your MSIX application 本節討論如何使用擴充功能和選用套件來擴充您的應用程式。This section discusses how you can to extend your application using extensions and optional packages.

新增現代化 Windows 10 體驗Add modern Windows 10 experiences

在為您的傳統型應用程式建立 MSIX 套件之後,可以使用 UWP API、套件擴充功能和 UWP 元件,提供現代化和吸引人的 Windows 10 體驗 (例如動態磚和通知)。After you create an MSIX package for your desktop app, you can use UWP APIs, package extensions, and UWP components to light up modern and engaging Windows 10 experiences such as live tiles and notifications.

使用 UWP API 增強功能Enhance with UWP APIs

封裝應用程式之後,您就可以使用一些功能,例如動態磚和推播通知等美化應用程式。Once you've packaged your app, you can light it up with features such as live tiles, and push notifications. 有些功能可大幅改善應用程式的參與程度,而且新增他們只需要花費您一點時間。Some of these capabilities can significantly improve the engagement level of your application and they cost you very little time to add. 一些增強功能則可能需要多一點程式碼。Some enhancements require a bit more code.

請參閱在傳統型應用程式中使用 UWP APISee Use UWP APIs in desktop applications.

整合套件擴充功能Integrate with package extensions

如果應用程式需要與系統整合 (例如:建立防火牆規則),請在應用程式的封裝資訊清單中描述這些項目,系統會替您完成其餘的工作。If your application needs to integrate with the system (For example: establish firewall rules), describe those things in the package manifest of your application and the system will do the rest. 針對大部分的工作,您完全不需要撰寫任何程式碼。For most of these tasks, you won't have to write any code at all. 只需在資訊清單中提供一些 XML,您就可以執行一些工作,像是在使用者登入時執行處理程序、將應用程式與檔案總管整合,以及將應用程式加入在其他應用程式中出現的列印目標清單。With a bit of XML in the manifest, you can do things like start a process when the user logs on, integrate your application into File Explorer, and add your application a list of print targets that appear in other apps.

請參閱整合您的傳統型應用程式與套件擴充功能See Integrate your desktop application with package extensions.

使用 UWP 元件進行擴充Extend with UWP components

有些 Windows 10 體驗 (例如:具有觸控功能的 UI 頁面) 必須在現代化應用程式容器中執行。Some Windows 10 experiences (For example: a touch-enabled UI page) must run inside of a modern app container. 一般而言,您應該先判斷是否可以使用 UWP API 透過增強現有的傳統型應用程式來新增體驗。In general, you should first determine whether you can add your experience by enhancing your existing desktop application with UWP APIs. 如果您必須使用 UWP 元件來達成體驗,則可以將 UWP 專案加入方案,並使用應用程式服務在傳統型應用程式和 UWP 元件之間通訊。If you have to use a UWP component, to achieve the experience, then you can add a UWP project to your solution and use app services to communicate between your desktop application and the UWP component.

請參閱使用 UWP 元件擴充您的傳統型應用程式See Extend your desktop application with UWP components.