在應用程式安裝程式檔案中設定更新設定Configure update settings in the App Installer file

如應用程式安裝程式檔案 總覽所述,您可以在應用程式安裝程式檔中設定應用程式的更新行為。As mentioned in App Installer file overview, you can configure the update behavior of the app in the App Installer file. 本文將探討更新選項及其各自的取捨。This article explores the update options and their respective trade-offs.

您可以使用 UpdateSettings 元素來設定應用程式的更新行為。You can configure the update behavior of the app by using the UpdateSettings element. 在這裡,我們將探索更新選項及其各自的取捨。Here we explore the update options and their respective trade-offs.

簡單地說,您可以選擇以兩種不同的方式來檢查是否有更新:In short, you can choose to check for updates two different ways:

  1. 獨立于使用者啟動應用程式。Independently of the user launching the app.
  2. 只有當使用者啟動應用程式時。Only when the user launches the app.

此外,您可以選擇以兩種不同的方式套用更新:Additionally, you can choose to apply updates in two different ways:

  1. 藉由通知使用者提示。By informing the user with a prompt.
  2. 無訊息通知使用者。Silently, without informing the user.

最後,當您通知使用者有更新時,您可以強制他們進行更新,然後讓他們啟動應用程式,或者您可以讓他們啟動應用程式,並在時機時套用更新。Finally, when you inform the user of an update, you can either force them to take the update before allowing them to launch the app, or you can allow them to launch the app and apply the update at an opportune time.

UpdateSettings元素可以有下列子項目:The UpdateSettings element can have the following child elements:

應用程式安裝程式檔案更新設定App Installer file update setting 最小 Windows 10 版本Min Windows 10 Version
OnLaunchOnLaunch 17091709
HoursBetweenUpdateChecksHoursBetweenUpdateChecks 18031803
AutomaticBackgroundTaskAutomaticBackgroundTask 18031803
UpdateBlocksActivationUpdateBlocksActivation 19031903
ShowPromptShowPrompt 19031903
ForceUpdateFromAnyVersionForceUpdateFromAnyVersion 19031903
  • OnLaunch:在啟動時檢查更新。OnLaunch: Checks for updates on launch. 這種類型的更新可以顯示 UI,且具有下列屬性:This type of update can show UI and has the following attributes:

    • HoursBetweenUpdateChecks:一個整數,這個整數表示系統將檢查應用程式更新的 () 時數的頻率。HoursBetweenUpdateChecks: An integer that indicates how often (in how many hours) the system will check for updates to the app. "0" 到 "255" (含)。“0” to “255” inclusive. 如果未指定此值) ,預設值為 24 (。The default value is 24 (if this value is not specified). 例如,如果 HoursBetweenUpdateChecks = 3,然後當使用者啟動應用程式時,如果系統未在過去3小時內檢查更新,它就會立即檢查更新。For example if HoursBetweenUpdateChecks = 3 then when the user launches the app, if the system has not checked for updates within the past 3 hours, it will check for updates now.

    • ShowPrompt:布林值,決定是否要向使用者顯示 UI。ShowPrompt: A boolean that determines if UI will be shown to the user. Windows 10 1903 版及更新版本支援此值。This value is supported on Windows 10, version 1903 and later.

    • UpdateBlocksActivation:布林值,決定向使用者顯示的 UI 是否允許使用者在不需要更新的情況下啟動應用程式,或是使用者必須在啟動應用程式之前進行更新。UpdateBlocksActivation: A boolean that determines if the UI shown to the user allows the user to launch the app without taking the update, or if the user must take the update before launching the app. 只有當 ShowPrompt 設定為 "true" 時,才可以將這個屬性設定為 "true"。This attribute can be set to “true” only if ShowPrompt is set to “true”. UpdateBlocksActivation= "true" 表示使用者將看到的 UI,可讓使用者進行更新或關閉應用程式。UpdateBlocksActivation=“true” means the UI the user will see, allows the user to take the update or close the app. UpdateBlocksActivation= "false" 表示使用者將看到的 UI,可讓使用者進行更新或啟動應用程式,而不需更新。UpdateBlocksActivation="false" means the UI the user will see, allows the user to take the update or start the app without updating. 在後者的情況下,更新會在時機階段以無訊息模式套用。In the latter case, the update will be applied silently at an opportune time. Windows 10 1903 版及更新版本支援此值。This value is supported on Windows 10, version 1903 and later.

      注意

      如果 UpdateBlocksActivation 設定為 true,則 ShowPrompt 必須設定為 true。ShowPrompt needs to be set to true if UpdateBlocksActivation is set to true.

  • AutomaticBackgroundTask:在背景每隔8小時檢查一次更新,不論使用者是否啟動應用程式。AutomaticBackgroundTask: Checks for updates in the background every 8 hours independently of whether the user launched the app. 這種類型的更新無法顯示 UI。This type of update cannot show UI.

  • ForceUpdateFromAnyVersion:允許應用程式從版本 x 更新至 x + + 版本,或從版本 x 降級為版本 x--。ForceUpdateFromAnyVersion: Allows the app to update from version x to version x++ or to downgrade from version x to version x--. 如果沒有這個元素,應用程式只能移至較高的版本。Without this element, the app can only move to a higher version.