<deployment>元素(ClickOnce 部署)<deployment> element (ClickOnce deployment)

識別用於更新部署及公開至系統的屬性。Identifies the attributes used for the deployment of updates and exposure to the system.

語法Syntax


      <deployment
   install
   minimumRequiredVersion
   mapFileExtensions
   disallowUrlActivation
   trustUrlParameters
>
   <subscription>
         <update>
            <beforeApplicationStartup/>
            <expiration
               maximumAge
               unit
            />
         </update>
   </subscription>
   <deploymentProvider
      codebase
   />
</deployment>

元素和屬性Elements and attributes

deployment 項目是必要的,且位於 urn:schemas-microsoft-com:asm.v2 命名空間。The deployment element is required and is in the urn:schemas-microsoft-com:asm.v2 namespace. 該項目具有下列屬性。The element has the following attributes.

屬性Attribute 描述Description
install 必要項。Required. 指定此應用程式是否會在 Windows [開始] 功能表和 [控制台] [新增或移除程式] 應用程式中定義目前狀態。Specifies whether this application defines a presence on the Windows Start menu and in the Control Panel Add or Remove Programs application. 有效值為 truefalseValid values are true and false. 如果falseClickOnceClickOnce ,一律會從網路執行這個應用程式的最新版本, subscription而且不會辨識元素。If false, ClickOnceClickOnce will always run the latest version of this application from the network, and will not recognize the subscription element.
minimumRequiredVersion 選擇性。Optional. 指定此應用程式可在用戶端上執行的最小版本。Specifies the minimum version of this application that can run on the client. 如果應用程式的版本號碼小於部署資訊清單中提供的版本號碼,應用程式將不會執行。If the version number of the application is less than the version number supplied in the deployment manifest, the application will not run. 版本號碼必須以格式N.N.N.N指定,其中N是不帶正負號的整數。Version numbers must be specified in the format N.N.N.N, where N is an unsigned integer. 如果屬性為falseminimumRequiredVersion則不得設定。 installIf the install attribute is false, minimumRequiredVersion must not be set.
mapFileExtensions 選擇性。Optional. 預設值為 falseDefaults to false. 如果true為,則部署中的所有檔案都必須具有 .deploy 副檔名。If true, all files in the deployment must have a .deploy extension. ClickOnceClickOnce當這些檔案從 Web 服務器下載時,將會立即從這些檔案中去除。will strip this extension off these files as soon as it downloads them from the Web server. 如果您使用Visual StudioVisual Studio來發行應用程式,它會自動將此延伸模組新增至所有檔案。If you publish your application by using Visual StudioVisual Studio, it automatically adds this extension to all files. 此參數可從 Web 服務器下載ClickOnceClickOnce部署中的所有檔案,以封鎖以「不安全」副檔名結尾的檔案(例如 .exe)的傳輸。This parameter allows all the files within a ClickOnceClickOnce deployment to be downloaded from a Web server that blocks transmission of files ending in "unsafe" extensions such as .exe.
disallowUrlActivation 選擇性。Optional. 預設值為 falseDefaults to false. 如果true是,請在 Internet Explorer 中按一下 url 或輸入 url,以防止已安裝的應用程式啟動。If true, prevents an installed application from being started by clicking the URL or entering the URL into Internet Explorer. install如果屬性不存在,則會忽略這個屬性。If the install attribute is not present, this attribute is ignored.
trustURLParameters 選擇性。Optional. 預設值為 falseDefaults to false. 如果true是,允許 URL 包含傳入應用程式的查詢字串參數,就像命令列引數一樣,會傳遞至命令列應用程式。If true, allows the URL to contain query string parameters that are passed into the application, much like command-line arguments are passed to a command-line application. 如需詳細資訊,請參閱如何:在線上 ClickOnce 應用程式中擷取查詢字串資訊For more information, see How to: Retrieve Query String Information in an Online ClickOnce Application.

如果屬性為true falsetrustUrlParameters則必須從資訊清單中排除,或明確地設定為。 disallowUrlActivationIf the disallowUrlActivation attribute is true, trustUrlParameters must either be excluded from the manifest, or explicitly set to false.

deployment元素也包含下列子項目。The deployment element also contains the following child elements.

訂用帳戶subscription

選擇性。Optional. update包含元素。Contains the update element. subscription 項目沒有任何屬性。The subscription element has no attributes. 如果元素不存在,應用程式永遠不會掃描更新。 ClickOnceClickOnce subscriptionIf the subscription element does not exist, the ClickOnceClickOnce application will never scan for updates. 如果deployment元素install的屬性為false,則會忽略subscription元素,因為從網路啟動的應用程式一律使用ClickOnceClickOnce最新版本。If the install attribute of the deployment element is false, the subscription element is ignored, because a ClickOnceClickOnce application that is launched from the network always uses the latest version.

更新update

必要項。Required. 這個元素是subscription元素的子系,而且包含beforeApplicationStartupexpiration專案。This element is a child of the subscription element and contains either the beforeApplicationStartup or the expiration element. beforeApplicationStartupexpiration不能同時在相同的部署資訊清單中指定。beforeApplicationStartup and expiration cannot both be specified in the same deployment manifest.

update 項目沒有任何屬性。The update element has no attributes.

beforeApplicationStartupbeforeApplicationStartup

選擇性。Optional. 這個元素是update元素的子系,而且沒有任何屬性。This element is a child of the update element and has no attributes. 當元素存在時,如果用戶端在線上, ClickOnceClickOnce則會在檢查更新時封鎖應用程式。 beforeApplicationStartupWhen the beforeApplicationStartup element exists, the application will be blocked when ClickOnceClickOnce checks for updates, if the client is online. 如果這個元素不存在, ClickOnceClickOnce將會先根據為expiration元素指定的值來掃描更新。If this element does not exist, ClickOnceClickOnce will first scan for updates based on the values specified for the expiration element. beforeApplicationStartupexpiration不能同時在相同的部署資訊清單中指定。beforeApplicationStartup and expiration cannot both be specified in the same deployment manifest.

到期expiration

選擇性。Optional. 這個元素是update元素的子系,而且沒有子系。This element is a child of the update element, and has no children. beforeApplicationStartupexpiration不能同時在相同的部署資訊清單中指定。beforeApplicationStartup and expiration cannot both be specified in the same deployment manifest. 當更新檢查發生並偵測到更新的版本時,新版本會在現有版本執行時快取。When the update check occurs and an updated version is detected, the new version caches while the existing version runs. 新版本接著會在下一次啟動ClickOnceClickOnce應用程式時安裝。The new version then installs on the next launch of the ClickOnceClickOnce application.

expiration元素支援下列屬性。The expiration element supports the following attributes.

屬性Attribute 描述Description
maximumAge 必要項。Required. 識別目前的更新在應用程式執行更新檢查之前應如何成為舊的版本。Identifies how old the current update should become before the application performs an update check. 時間單位是由unit屬性所決定。The unit of time is determined by the unit attribute.
unit 必要項。Required. 識別的時間maximumAge單位。Identifies the unit of time for maximumAge. 有效的單位hoursdays、和weeksValid units are hours, days, and weeks.

deploymentProviderdeploymentProvider

針對 .NET Framework 2.0,如果部署資訊清單包含subscription區段,則需要這個元素。For the .NET Framework 2.0, this element is required if the deployment manifest contains a subscription section. 針對 .NET Framework 3.5 和更新版本,這個元素是選擇性的,而且會預設為探索到部署資訊清單的伺服器和檔案路徑。For the .NET Framework 3.5 and later, this element is optional, and will default to the server and file path in which the deployment manifest was discovered.

這個元素是 deployment 元素的子項,並具有下列屬性。This element is a child of the deployment element and has the following attribute.

屬性Attribute 描述Description
codebase 必要項。Required. 識別用來更新ClickOnceClickOnce應用程式之部署資訊清單的「統一資源識別元(URI)」位置。Identifies the location, as a Uniform Resource Identifier (URI), of the deployment manifest that is used to update the ClickOnceClickOnce application. 此元素也允許轉送以 CD 為基礎之安裝的更新位置。This element also allows for forwarding update locations for CD-based installations. 必須是有效的 URI。Must be a valid URI.

備註Remarks

您可以將ClickOnceClickOnce應用程式設定為在啟動時掃描更新、在啟動後掃描更新,或永遠不檢查更新。You can configure your ClickOnceClickOnce application to scan for updates on startup, scan for updates after startup, or never check for updates. 若要在啟動時掃描更新,請確定beforeApplicationStartup專案是否存在於update元素之下。To scan for updates on startup, ensure that the beforeApplicationStartup element exists under the update element. 若要在啟動之後掃描更新,請確定expiration update專案位於元素底下,而且已提供更新間隔。To scan for updates after startup, ensure that the expiration element exists under the update element, and that update intervals are provided.

若要停用更新檢查,請subscription移除元素。To disable checking for updates, remove the subscription element. 當您在部署資訊清單中指定永遠不會掃描更新時,您仍然可以使用CheckForUpdate方法來手動檢查更新。When you specify in the deployment manifest to never scan for updates, you can still manually check for updates by using the CheckForUpdate method.

如需有關 deploymentProvider 如何與更新產生關聯的詳細資訊,請參閱選擇 ClickOnce 更新策略For more information on how deploymentProvider relates to updates, see Choosing a ClickOnce Update Strategy.

範例Examples

下列程式碼範例說明deployment ClickOnceClickOnce部署資訊清單中的元素。The following code example illustrates a deployment element in a ClickOnceClickOnce deployment manifest. 此範例會使用deploymentProvider專案來表示慣用的更新位置。The example uses a deploymentProvider element to indicate the preferred update location.

<deployment install="true" minimumRequiredVersion="2.0.0.0" mapFileExtension="true" trustUrlParameters="true">
    <subscription>
      <update>
        <expiration maximumAge="6" unit="hours" />
      </update>
    </subscription>
    <deploymentProvider codebase="http://www.adatum.com/MyApplication.application" />
  </deployment>

另請參閱See also