了解您的安裝程式Know your installer

本文列出將現有安裝程式轉換成 MSIX 之前需要知道的事項。This article lists the things you need to know before you convert your existing installer into an MSIX. 您可能不需要這麼多,就能讓您的應用程式準備好進行封裝程式,但如果下列任何專案適用于您的應用程式,則必須在封裝之前加以解決。You might not have to do much to get your application ready for the packaging process, but if any of the items below applies to your application, you need to address it before packaging.

  • 您的應用程式有服務Your application has a service. 我們支援 使用服務來轉換應用程式,但請務必記住轉換服務的 限制We support converting applications with services, but its important to keep in mind the limitations to converting a service. 轉換之後,您將需要系統管理員許可權,才能安裝包含服務的 MSIX。After conversion, you will need admin elevation in order to install the MSIX that contains a service. 您可以從 MSIX 封裝工具的 [版本 1.2019.1220.0] 開始轉換具有服務的應用程式,而且您可以從 Windows 10 2020 版的版開始,使用服務來部署 MSIX。You can convert an application with services beginning in version 1.2019.1220.0 of the MSIX Packaging Tool, and you can deploy the MSIX with services beginning in the spring 2020 release of Windows 10.

  • 您的安裝程式需要重新開機Your installer requires a restart. 如果您的安裝程式需要 重新開機,從版本1.2019.701.0 開始的 MSIX 封裝工具支援此功能。If your installer requires a restart, this is supported in the MSIX Packaging Tool beginning in version 1.2019.701.0. 如果您的安裝程式傳回不尋常的結束代碼來指出它需要重新開機,您應該將它新增至 MSIX 封裝工具設定的 [ 重新開機結束代碼 ] 區段。If your installer returns an uncommon exit code to indicate it needs a restart, you should add it to the restart exit codes section of the MSIX Packaging Tool settings.

  • 您的 .net 應用程式需要的 .NET Framework 版本早于 4.6.2Your .NET application requires a version of the .NET Framework earlier than 4.6.2. 如果您要封裝 .NET 應用程式,我們建議您的應用程式以 .NET Framework 4.6.2 或更新版本為目標。If you are packaging a .NET application, we recommend that your application target .NET Framework 4.6.2 or later. 安裝和執行已封裝的桌面應用程式的能力,是在 Windows 10 中首次引進,版本 1607 (也稱為年度更新) ,而此 OS 版本預設包含 .NET Framework 4.6.2。The ability to install and run packaged desktop applications was first introduced in Windows 10, version 1607 (also called the Anniversary Update), and this OS version includes the .NET Framework 4.6.2 by default. 較新的作業系統版本包含 .NET Framework 的較新版本。Later OS versions include later versions of the .NET Framework. 如需 Windows 10 的較新版本包含哪些 .NET 版本的完整清單,請參閱 這篇文章For a full list of what versions of .NET are included in later versions of Windows 10, see this article.

    在封裝的桌面應用程式中,以4.6.2 之前的版本為目標 .NET Framework,在大部分情況下應該都能運作。Targeting versions of the .NET Framework earlier than 4.6.2 in packaged desktop applications is expected to work in most cases. 但是,如果您的目標版本比4.6.2 還舊,您應該先完整測試已封裝的桌面應用程式,再將其散發給使用者。However, if you target an earlier version than 4.6.2, you should fully test your packaged desktop application before distributing it to users.

    • 4.0-4.6.1:以這些 .NET Framework 版本為目標的應用程式預期會在4.6.2 或更新版本上執行,而不會有任何問題。4.0 - 4.6.1: Applications that target these versions of the .NET Framework are expected to run without issues on 4.6.2 or later. 因此,這些應用程式應該在 Windows 10 1607 版或更新版本上安裝並執行,而不需要變更作業系統隨附的 .NET Framework 版本。Therefore, these applications should install and run without changes on Windows 10, version 1607 or later with the version of the .NET Framework that is included with the OS.

    • 2.0 和3.5:在我們的測試中,以這些 .NET Framework 版本為目標的已封裝桌面應用程式通常可正常運作,但在某些情況下可能會表現出效能問題。2.0 and 3.5: In our testing, packaged desktop applications that target these versions of the .NET Framework generally work but may exhibit performance issues in some scenarios. 為了讓這些封裝的應用程式能夠安裝和執行, .NET Framework 3.5 功能 必須安裝在目的電腦上 (這項功能也包含 .NET Framework 2.0 和 3.0) 。In order for these packaged applications to install and run, the .NET Framework 3.5 feature must be installed on the target machine (this feature also includes .NET Framework 2.0 and 3.0). 您也應該在封裝這些應用程式之後,徹底進行測試。You should also test these applications thoroughly after you package them.

  • 您的應用程式需要驅動程式Your application requires a driver. MSIX 不支援驅動程式。MSIX does not support drivers.

  • 您的應用程式會將資料寫入至 AppData 資料夾或登錄,以與其他應用程式共用資料Your application writes to the AppData folder or to the registry with the intention of sharing data with another app. 轉換之後,AppData 會重新導向至本機應用程式資料存放區,也就是每個應用程式的私用存放區。After conversion, AppData is redirected to the local app data store, which is a private store for each app.

    您應用程式寫入 HKEY_LOCAL_MACHINE 登錄區的所有專案都會重新導向至隔離的二進位檔案,而您的應用程式寫入 HKEY_CURRENT_USER 登錄區的任何專案,都會放入私人的個別使用者、每個應用程式位置。All entries that your application writes to the HKEY_LOCAL_MACHINE registry hive are redirected to an isolated binary file and any entries that your application writes to the HKEY_CURRENT_USER registry hive are placed into a private per-user, per-app location. 如需檔案和登錄重新導向的詳細資訊,請參閱傳統型橋接器的幕後作業For more details about file and registry redirection, see Behind the scenes of the Desktop Bridge.

  • 您的應用程式會寫入至應用程式的安裝目錄Your application writes to the install directory for your app. 例如,您的應用程式會寫入記錄檔,而您會將該檔案放在與 exe 相同的目錄中。For example, your application writes to a log file that you put in the same directory as your exe. 因為資料夾受到保護,所以不支援此功能。This isn't supported because the folder is protected. 建議您將寫入至另一個位置,例如本機應用程式資料存放區。We recommend writing to another location like the local app data store. 我們新增了一項功能,可在1809和更新版本中使用。We have added a capability that allows this in 1809 and later.

  • 您的應用程式會使用目前的工作目錄Your application uses the current working directory. 在執行時間,您已封裝的桌面應用程式將無法取得您先前在桌面上指定的相同工作目錄。.LNK 快捷方式。At runtime, your packaged desktop application won't get the same working directory that you previously specified in your desktop .LNK shortcut. 如果有正確的目錄,讓您的應用程式正確運作,您需要在執行時間變更您的 CWD。You need to change your CWD at runtime if having the correct directory is important for your application to function correctly.

  • 您的應用程式會從 Windows 並存資料夾安裝並載入元件Your application installs and loads assemblies from the Windows side-by-side folder. 例如,您的應用程式會使用 C 執行時間程式庫 VC8 或 VC9,而且會從 Windows 並存資料夾動態連結它們,這表示您的程式碼會使用共用資料夾中的一般 DLL 檔案,例如 C:\Windows\WinSxS。For example, your application uses C runtime libraries VC8 or VC9 and is dynamically linking them from Windows side-by-side folder, meaning your code is using the common DLL files from a shared folder, such as C:\Windows\WinSxS. 不支援這個動作。This is not supported. 您必須以靜態方式連結它們,方法是直接將可轉散發的程式庫檔案連結到您的程式碼。You will need to statically link them by linking to the redistributable library files directly into your code.

    注意

    如果您的應用程式需要寫入安裝目錄,或使用目前的工作目錄,您也可以考慮使用 套件支援架構 ,將執行時間修復新增至套件。If your app needs to write to the installation directory or use the current working directory, you can also consider adding a runtime fixup using the Package Support Framework to your package. 如需詳細資料,請參閱這篇文章For more details, see this article.