使用 Visual Studio 建立應用程式安裝程式檔案Create an App Installer file with Visual Studio

從 Windows 10 版本1803開始, Visual Studio 2017, Update 15.7, 可以將側載應用程式設定為使用.appinstaller檔案接收自動更新。Starting with Windows 10, Version 1803, and Visual Studio 2017, Update 15.7, sideloaded apps can be configured to receive automatic updates using an .appinstaller file. Visual Studio 支援啟用這些更新。Visual Studio supports enabling these updates.

應用程式安裝程式檔案位置App Installer file location

.appinstaller檔案可以裝載於共用位置 (例如 HTTP 端點或 UNC 共用資料夾),並包含了應用程式套件的安裝路徑。The .appinstaller file can be hosted in a shared location like a HTTP endpoint or a UNC shared folder, and includes the path to find the app packages to be installed. 使用者從共用位置安裝應用程式以及啟用新更新的定期檢查。Users install the app from the shared location and enable periodic checks for new updates.

將專案設定為以正確的 Windows 版本為目標Configure the project to target the correct Windows version

您可以在建立專案時設定TargetPlatformMinVersion屬性,或稍後從專案屬性變更屬性。You can either configure the TargetPlatformMinVersion property when you create the project, or change it later from the project properties.

重要

只有當TargetPlatformMinVersion是 Windows 10 1803 版或更新版本時, 才會產生應用程式安裝程式檔案。The app installer file is only generated when the TargetPlatformMinVersion is Windows 10, Version 1803 or greater.

建立套件Create packages

若要透過側載散發應用程式, 您必須建立應用程式套件 (.appx/. msix) 或應用程式配套 (.appxbundle/.msixbundle), 並將它發佈到共用位置。To distribute an app via sideloading, you must create an app package (.appx/.msix) or app bundle (.appxbundle/.msixbundle) and publish it in a shared location.

若要這樣做,請依照下列步驟使用 Visual Studio 中的 [建立應用程式套件] 精靈。To do that, use the Create App Packages wizard in Visual Studio with the following steps.

  1. 在專案上按一下滑鼠右鍵,然後選擇 [市集] -> [建立應用程式套件]。 Right-click the project and choose Store -> Create App Packages.

    導覽至 [建立應用程式套件] 的操作功能表

    [建立應用程式套件] 精靈便會出現。 The Create App Packages wizard appears.

  2. 選取 [我想要建立側載套件]Select I want to create packages for sideloading. [啟用自動更新]and Enable automatic updates

    顯示的 [建立您的套件] 對話方塊視窗

    只有在讓專案的 TargetPlatformMinVersion 設定為正確版本的 Windows 10,才會啟用 [啟用自動更新]Enable automatic updates is enabled only if the project's TargetPlatformMinVersion is set to the correct version of Windows 10.

  3. [選取並設定套件] 對話方塊可讓您選取支援的架構設定。The Select and Configure Packages dialog allows you to select the supported architecture configurations. 如果您選擇套件組合,它將會產生單一安裝程式,但是如果您不想要套件組合並想要每個架構一個套件的話,也可以為每個架構取得一個安裝程式檔案。If you select a bundle it will generate a single installer, however if you don't want a bundle and prefer one package per architecture you will also get one installer file per architecture. 如果您不確定選擇哪些架構,或想要深入了解各種裝置所使用的架構,請查看應用程式套件架構If you're unsure which architecture(s) to choose, or want to learn more about which architectures are used by various devices, see App package architectures.

  4. 設定任何其他詳細資料,例如版本編號或套件輸出位置。Configure any additional details, such as version numbering or the package output location.

    顯示套件設定的 [建立應用程式套件] 視窗

  5. 當您在步驟 2 選取 [啟用自動更新][設定更新設定] 對話方塊會出現。If you checked Enable automatic updates in Step 2, the Configure Update Settings dialog will appear. 在這裡,您可以指定 [安裝 URL] 和更新檢查的頻率。Here, you can specify the Installation URL and the frequency of update checks.

    以發佈位置設定進行更新設定視窗

  6. 已成功封裝應用程式時,對話方塊會顯示包含應用程式套件輸出資料夾的位置。When your app has been successfully packaged, a dialog will display the location of the output folder containing your app package. 輸出資料夾包含側載應用程式所需的所有檔案,包括可用來促銷應用程式的 HTML 頁面。The output folder includes all the files needed to sideload the app, including an HTML page that can be used to promote your app.

發佈套件Publish packages

若要讓應用程式可用,產生的檔案必須發行至指定的位置:To make the application available the generated files must be published to the location specified:

發佈至共用資料夾 (UNC)Publish to shared folders (UNC)

如果您想要透過通用命名規格 (UNC) 共用資料夾發佈套件,請將應用程式套件輸出資料夾和安裝 URL(如需詳細資訊請參閱步驟 6)設定為相同的路徑。If you want to publish your packages over Universal Naming Convention (UNC) shared folders, configure the app package output folder and the Installation URL (see Step 6 for details) to the same path. 精靈會在正確的位置產生檔案,而且使用者會從相同的路徑取得應用程式與未來的更新。The wizard will generate the files in the correct location, and users will get both the app and future updates from the same path.

發佈到網站位置 (HTTP)Publish to a web location (HTTP)

發佈至網站位置需要存取權以便將內容發佈至網頁伺服器,請確認最終 URL 符合精靈中定義的安裝 URL(如需詳細資訊請參閱步驟 6)。Publishing to a web location requires access to publish content to the web server, making sure the final URL matches the Installation URL defined in the wizard (see Step 6 for details). 通常檔案傳輸通訊協定 (FTP) 或 SSH 檔案傳輸通訊協定 (SFTP) 會用來上傳檔案,但根據您的網站提供者,還有類似 MSDeploy、SSH 或 Blob 儲存等其他發佈方法。Typically, File Transfer Protocol (FTP) or SSH File Transfer Protocol (SFTP) are used to upload the files, but there are other publishing methods like MSDeploy, SSH, or Blob storage, depending on your web provider.

若要設定網頁伺服器,您必須驗證用於使用中的檔案類型的 MIME 類型。To configure the web server you must verify the MIME types used for the file types in use. 此範例中為適用於 Internet Information Services (IIS) 的 web.configThis example is of the web.config for Internet Information Services (IIS):

<configuration>
  <system.webServer>
    <staticContent>
      <mimeMap fileExtension=".appx" mimeType="application/vns.ms-appx" />
      <mimeMap fileExtension=".appxbundle" mimeType="application/vns.ms-appx" />
      <mimeMap fileExtension=".appinstaller" mimeType="application/xml" />
    </staticContent>  
  </system.webServer>  
</configuration>