部署 Web 套件Deploying Web Packages

Jason 先生by Jason Lee

下載 PDFDownload PDF

本主題說明如何使用 Internet Information Services (IIS) Web 部署工具(Web Deploy)2.0,將 web 部署套件發行至遠端伺服器。This topic describes how you can publish web deployment packages to a remote server by using the Internet Information Services (IIS) Web Deployment Tool (Web Deploy) 2.0.

有兩種主要方式可將 web 封裝部署到遠端伺服器:There are two main ways in which you can deploy a web package to a remote server:

  • 您可以直接使用 Msdeploy.exe 命令列公用程式。You can use the MSDeploy.exe command-line utility directly.
  • 您可以執行組建程式所產生的 [專案名稱]. deploy .cmd檔案。You can run the [project name].deploy.cmd file that the build process generates.

不論您使用哪種方法,最終結果都相同。The end result is the same regardless of which approach you use. 基本上,所有的 .deploy .cmd檔案都是以一些預先決定的值執行 msdeploy.exe,因此您不需要提供太多資訊,就能部署封裝。Essentially, all the .deploy.cmd file does is to run MSDeploy.exe with some predetermined values, so that you don't have to provide as much information in order to deploy the package. 這可簡化部署程式。This simplifies the deployment process. 另一方面,使用 Msdeploy.exe 直接提供您更大的彈性,而不是確切部署套件的方式。On the other hand, using MSDeploy.exe directly gives you a lot more flexibility over exactly how your package is deployed.

您所使用的方法將取決於各種因素,包括您在部署程式上需要多少控制,以及您的目標是 Web Deploy 遠端代理程式服務還是 Web Deploy 處理常式。Which approach you use will depend on a variety of factors, including how much control you require over the deployment process and whether you're targeting the Web Deploy Remote Agent service or the Web Deploy Handler. 本主題說明如何使用每種方法,並識別每個方法的適當時機。This topic explains how to use each approach and identifies when each approach is appropriate.

本主題中的工作和逐步解說假設:The tasks and walkthroughs in this topic assume that:

執行 [專案名稱] 。部署 .cmd檔案是部署 web 封裝最簡單的方式。Running the [project name].deploy.cmd file is the simplest way to deploy a web package. 特別是,使用 .deploy檔案比直接使用 msdeploy.exe 提供下列優點:In particular, using the .deploy.cmd file offers these advantages over using MSDeploy.exe directly:

  • 您不需要指定 web 部署套件—的位置 。 .cmd檔案已知道其所在位置。You don't need to specify the location of the web deployment package—the .deploy.cmd file already knows where it is.
  • 您不需要指定SetParameters —的位置。 .cmd檔案已知道其所在位置。You don't need to specify the location of the SetParameters.xml file—the .deploy.cmd file already knows where it is.
  • 您不需要指定來源和目的地 Msdeploy.exe 提供者— 。部署 .cmd檔案已經知道要使用的值。You don't need to specify source and destination MSDeploy providers—the .deploy.cmd file already knows which values to use.
  • 您不需要指定 Msdeploy.exe 作業設定— 。部署 .cmd檔案會自動將常用的值新增至 msdeploy.exe 命令。You don't need to specify MSDeploy operation settings—the .deploy.cmd file adds the commonly required values to the MSDeploy.exe command automatically.

在使用 .deploy檔案來部署 web 封裝之前,您應該確定:Before you use the .deploy.cmd file to deploy a web package, you should ensure that:

  • Deploy .cmd檔案,也就是 [project name]。SetParameters .xml檔案和 web 封裝([專案名稱]。zip)位於相同的資料夾中。The .deploy.cmd file, the [project name].SetParameters.xml file, and the web package ([project name].zip) are in the same folder.
  • Web Deploy (Msdeploy.exe)安裝在執行 . Deploy .cmd檔案的電腦上。Web Deploy (MSDeploy.exe) is installed on the computer that runs the .deploy.cmd file.

Deploy .cmd檔案支援各種命令列選項。The .deploy.cmd file supports various command-line options. 當您從命令提示字元執行檔案時,這是基本語法:When you run the file from a command prompt, this is the basic syntax:

[project name].deploy.cmd [/T | /Y]
                          [/M:<computer name>]
                          [/A:<Basic | NTLM>]
                          [/U:<user name>]
                          [/P:<password>]
                          [/L]
                          [/G:<true | false>]
                          [Additional MSDeploy.exe flags]

您必須指定 /t旗標或 /y旗標,以指出您想要分別執行試用或即時部署(請勿在相同的命令中使用這兩個旗標)。You must specify either a /T flag or a /Y flag, to indicate whether you want to perform a trial run or a live deployment respectively (don't use both flags in the same command). 下表說明每個旗標的用途。This table explains the purpose of each of these flags.

旗標Flag 說明Description
一起/T 使用 – whatif旗標呼叫 msdeploy.exe,這表示試用版執行。Calls MSDeploy.exe with the –whatif flag, which indicates a trial run. 它不會部署封裝,而是會建立一份報告,說明部署套件時所發生的情況。Rather than deploying the package, it creates a report of what would happen if you did deploy the package.
/Y/Y 呼叫 Msdeploy.exe,但不含 – whatif旗標。Calls MSDeploy.exe without the –whatif flag. 這會將封裝部署到本機電腦或指定的目的地伺服器。This deploys the package to the local computer or the specified destination server.
/M/M 指定目的地伺服器名稱或服務 URL。Specifies the destination server name or service URL. 如需您可以在這裡提供之值的詳細資訊,請參閱本主題中的端點考慮一節。For more information on the values you can provide here, see the Endpoint Considerations section in this topic. 如果您省略 /m旗標,封裝將會部署到本機電腦。If you omit the /M flag, the package will be deployed to the local computer.
/A/A 指定 Msdeploy.exe 應用來執行部署的驗證類型。Specifies the authentication type that MSDeploy.exe should use to perform the deployment. 可能的值為 [ NTLM ] 和 [基本]。Possible values are NTLM and Basic. 如果您省略 /a旗標,驗證類型會預設為NTLM以部署到 Web Deploy 遠端代理程式服務,以及部署至 Web Deploy 處理常式的基本If you omit the /A flag, the authentication type defaults to NTLM for deployment to the Web Deploy Remote Agent service and to Basic for deployment to the Web Deploy Handler.
/U/U 指定使用者名稱。Specifies the user name. 只有當您使用基本驗證時,才適用這種情況。This applies only if you're using basic authentication.
/P/P 指定密碼。Specifies the password. 只有當您使用基本驗證時,才適用這種情況。This applies only if you're using basic authentication.
/L/L 指出應該將封裝部署到本機 IIS Express 實例。Indicates that the package should be deployed to the local IIS Express instance.
/G/G 指定使用tempAgent 提供者設定來部署封裝。Specifies that the package is deployed using the tempAgent provider setting. 如果您省略 /g旗標,此值會預設為falseIf you omit the /G flag, the value defaults to false.

Note

每次組建程式建立 web 套件時,它也會建立名為 [project name]. deploy-readme的檔案,說明這些部署選項。Every time the build process creates a web package, it also creates a file named [project name].deploy-readme.txt that explains these deployment options.

除了這些旗標之外,您還可以將 Web Deploy 作業設定指定為額外的 。部署 .cmd參數。In addition to these flags, you can specify Web Deploy operation settings as additional .deploy.cmd parameters. 您指定的任何其他設定都只會傳遞至基礎的 Msdeploy.exe 命令。Any additional settings you specify are simply passed through to the underlying MSDeploy.exe command. 如需這些設定的詳細資訊,請參閱Web Deploy 作業設定For more information on these settings, see Web Deploy Operation Settings.

假設您想要執行deploy .cmd檔案,將 ContactManager 部署至測試環境。Suppose you want to deploy the ContactManager.Mvc web application project to a test environment by running the .deploy.cmd file. 您的測試環境已設定為使用 Web Deploy 遠端代理程式服務,如設定 Web Deploy 發佈的網頁伺服器(遠端代理程式)中所述。Your test environment is configured to use the Web Deploy Remote Agent service, as described in Configure a Web Server for Web Deploy Publishing (Remote Agent). 若要部署 web 應用程式,您需要完成接下來的步驟。To deploy the web application, you need to complete the next steps.

若要使用 deploy .cmd 檔案部署 web 應用程式To deploy a web application using the .deploy.cmd file

  1. 建立和封裝 web 應用程式專案,如建立和封裝 Web 應用程式專案中所述。Build and package the web application project, as described in Building and Packaging Web Application Projects.

  2. 修改ContactManager ,使其包含測試環境的正確參數值,如設定Web 封裝部署的參數中所述。Modify the ContactManager.Mvc.SetParameters.xml file to contain the correct parameter values for your test environment, as described in Configuring Parameters for Web Package Deployment.

  3. 開啟 [命令提示字元] 視窗,並流覽至ContactManager的位置。Open a Command Prompt window and navigate to the location of the ContactManager.Mvc.deploy.cmd file.

  4. 輸入此命令,然後按 Enter 鍵:Type this command, and then press Enter:

    ContactManager.Mvc.deploy.cmd /Y /M:TESTWEB1 /A:NTLM
    

在這個範例中:In this example:

  • /Y旗標表示您想要實際部署封裝,而不是執行試用版。The /Y flag indicates that you want to actually deploy the package, rather than doing a trial run.
  • /M旗標表示您想要將封裝部署到名為 TESTWEB1 的伺服器。The /M flag indicates that you want to deploy the package to the server named TESTWEB1. 在這個值中,Msdeploy.exe 會嘗試將封裝部署到位於 http://TESTWEB1/MSDeployAgentService的 Web Deploy 遠端代理程式服務。From this value, MSDeploy.exe will attempt to deploy the package to the Web Deploy Remote Agent service at http://TESTWEB1/MSDeployAgentService.
  • /A旗標表示您想要使用 NTLM 驗證。The /A flag indicates that you want to use NTLM authentication. 因此,您不需要指定使用者名稱和密碼。As such, you don't need to specify a user name and password.

若要說明如何使用 .deploy檔案簡化部署程式,請參閱當您執行ContactManager時所產生和執行的 msdeploy.exe 命令,方法是使用上面顯示的選項。To illustrate how using the .deploy.cmd file simplifies the deployment process, take a look at the MSDeploy.exe command that gets generated and executed when you run ContactManager.Mvc.deploy.cmd using the options shown above.

msdeploy.exe 
-source:package='C:\Users\matt.FABRIKAM\Desktop\ContactManager-03\ContactManager\
 Publish\Out\_PublishedWebsites\ContactManager.Mvc_Package\ContactManager.Mvc.zip' -dest:auto,computerName='TESTWEB1.fabrikam.net', authtype='NTLM',
 includeAcls='False' 
-verb:sync 
-disableLink:AppPoolExtension 
-disableLink:ContentExtension 
-disableLink:CertificateExtension 
-setParamFile:"C:\Users\matt.FABRIKAM\Desktop\ContactManager-03\ContactManager\
 Publish\Out\_PublishedWebsites\ContactManager.Mvc_Package\
 ContactManager.Mvc.SetParameters.xml"

如需使用deploy .cmd檔案來部署 web 封裝的詳細資訊,請參閱如何:使用 Deploy 檔案安裝部署套件For more information on using the .deploy.cmd file to deploy a web package, see How to: Install a Deployment Package Using the deploy.cmd File.

使用 Msdeploy.exeUsing MSDeploy.exe

雖然使用deploy .cmd檔案通常會簡化部署程式,但在某些情況下,最好直接使用 msdeploy.exe。Although using the .deploy.cmd file generally simplifies the deployment process, there are some situations when it's preferable to use MSDeploy.exe directly. 例如:For example:

  • 如果您想要以非系統管理員使用者的身分部署至 Web Deploy 處理常式,則無法使用deploy .cmd檔案。If you want to deploy to the Web Deploy Handler as a non-administrator user, you can't use the .deploy.cmd file. 這是因為 Web Deploy 2.0 中的錯誤,如端點考慮中所述。This is due to a bug in Web Deploy 2.0, as described under Endpoint Considerations.
  • 如果您想要在不同位置的不同SetParameters之間手動切換,您可能會想要直接使用 msdeploy.exe。If you want to manually switch between different SetParameters.xml files in different locations, you may prefer to use MSDeploy.exe directly.
  • 如果您想要覆寫數個 Msdeploy.exe 命令列引數,您可能會想要直接使用 Msdeploy.exe。If you want to override several MSDeploy.exe command-line arguments, you may prefer to use MSDeploy.exe directly.

當您使用 Msdeploy.exe 時,您必須提供三個重要的資訊片段:When you use MSDeploy.exe, you need to provide three key pieces of information:

  • – Source參數,表示資料的來源位置。A –source parameter that indicates where your data is coming from.
  • -Dest參數,指出資料的目的地。A –dest parameter that indicates where your data is going to.
  • –動詞參數,表示您想要執行的作業。A –verb parameter that indicates the operation you want to perform.

Msdeploy.exe 依賴Web Deploy 提供者來處理來源和目的地資料。MSDeploy.exe relies on Web Deploy providers to process source and destination data. Web Deploy 包含很多提供者,代表它可以—使用的應用程式和資料來源範圍,例如,SQL Server 資料庫、IIS web 伺服器、憑證、全域組件快取(GAC)元件、各種不同的設定檔,以及許多其他類型的資料的提供者。Web Deploy includes a lot of providers that represent the range of applications and data sources it can work with—for example, there are providers for SQL Server databases, IIS web servers, certificates, global assembly cache (GAC) assemblies, various different configuration files, and lots of other types of data. – Source參數和 – dest參數都必須指定提供者,格式為 – source: [providerName] = [location]。Both the –source parameter and the –dest parameter must specify a provider, in the form –source:[providerName]=[location]. 當您將 web 套件部署到 IIS 網站時,應該使用下列值:When you're deploying a web package to an IIS website, you should use these values:

  • –來源提供者一律是packageThe –source provider is always package. 例如:For example:

    -source:package='[path to web package]'
    
  • – Dest提供者一律是自動的。例如:The –dest provider is always auto. For example:

    -dest:auto='[server name or service URL]'
    
  • –動詞一律會同步The –verb is always sync.

    -verb:sync
    

此外,您還需要指定各種其他提供者特定的設定和一般作業設定In addition, you'll need to specify various other provider-specific settings and general operation settings. 例如,假設您想要將 ContactManager 的 Mvc web 應用程式部署到預備環境。For example, suppose you want to deploy the ContactManager.Mvc web application to a staging environment. 部署會將目標設為 Web Deploy 處理常式,而且必須使用基本驗證。The deployment will target the Web Deploy Handler and must use basic authentication. 若要部署 web 應用程式,您需要完成接下來的步驟。To deploy the web application, you need to complete the next steps.

使用 Msdeploy.exe 部署 web 應用程式To deploy a web application using MSDeploy.exe

  1. 建立和封裝 web 應用程式專案,如建立和封裝 Web 應用程式專案中所述。Build and package the web application project, as described in Building and Packaging Web Application Projects.

  2. 修改ContactManager以包含預備環境的正確參數值,如設定Web 封裝部署的參數中所述。Modify the ContactManager.Mvc.SetParameters.xml file to contain the correct parameter values for your staging environment, as described in Configuring Parameters for Web Package Deployment.

  3. 開啟 [命令提示字元] 視窗,並流覽至 Msdeploy.exe 的位置。Open a Command Prompt window and browse to the location of MSDeploy.exe. 這通常位於%PROGRAMFILES%\IIS\Microsoft Web Deploy V2\msdeploy.exe。This is typically at %PROGRAMFILES%\IIS\Microsoft Web Deploy V2\msdeploy.exe.

  4. 輸入此命令,然後按 Enter (忽略分行符號):Type this command, and then press Enter (disregard the line breaks):

    MSDeploy.exe
      -source:package="[path]\ContactManager.Mvc.zip"
      -dest:auto,
            computerName="https://stageweb1:8172/MSDeploy.axd?site=DemoSite",
            username="FABRIKAM\stagingdeployer",
            $CREDENTIAL_PLACEHOLDER$,
            authtype="Basic",
            includeAcls="False"
      -verb:sync
      -disableLink:AppPoolExtension
      -disableLink:ContentExtension
      -disableLink:CertificateExtension
      -setParamFile:"[path]\ContactManager.Mvc.SetParameters.xml"
      -allowUntrusted
    

在這個範例中:In this example:

  • – Source參數會指定封裝提供者,並指出 web 封裝的位置。The –source parameter specifies the package provider and indicates the location of the web package.
  • – Dest參數會指定auto提供者。The –dest parameter specifies the auto provider. ComputerName設定會在目的地伺服器上提供 Web Deploy 處理常式的服務 URL。The computerName setting provides the service URL of the Web Deploy Handler on the destination server. Authtype設定指出您想要使用基本驗證,因此您必須提供使用者名稱密碼The authtype setting indicates that you want to use basic authentication, and as such you need to provide a username and a password. 最後, includeAcls = "False" 設定表示您不想要將來源 web 應用程式中檔案的存取控制清單(acl)複製到目的地伺服器。Finally, the includeAcls="False" setting indicates that you don't want to copy the access control lists (ACLs) of the files in your source web application to the destination server.
  • – Verb: sync引數指出您想要在目的地伺服器上複寫來源內容。The –verb:sync argument indicates that you want to replicate the source content on the destination server.
  • – DisableLink引數表示您不想要在目的地伺服器上複寫應用程式集區、虛擬目錄設定或安全通訊端層(SSL)憑證。The –disableLink arguments indicate that you don't want to replicate application pools, virtual directory configuration, or Secure Sockets Layer (SSL) certificates on the destination server. 如需詳細資訊,請參閱Web Deploy 連結延伸模組。For more information, see Web Deploy Link Extensions.
  • – SetParamFile參數提供SetParameters的位置。The –setParamFile parameter provides the location of the SetParameters.xml file.
  • – AllowUntrusted參數指出 Web Deploy 應該接受不是由受信任的憑證授權單位單位所發行的 SSL 憑證。The –allowUntrusted switch indicates that Web Deploy should accept SSL certificates that were not issued by a trusted certification authority. 如果您要部署到 Web Deploy 處理常式,而且您已使用自我簽署憑證來保護服務 URL,您必須包含此參數。If you're deploying to the Web Deploy Handler, and you've used a self-signed certificate to secure the service URL, you need to include this switch.

自動化 Web 套件部署Automating Web Package Deployment

在許多企業案例中,您會想要將 web 套件部署為較大的單一步驟或自動化部署的一部分。In a lot of enterprise scenarios, you'll want to deploy your web packages as part of a larger single-step or automated deployment. 無論您是否選擇直接執行 .deploy檔案或使用 msdeploy.exe 來部署 web 套件,您都可以參數化命令,並從 Microsoft Build Engine (MSBuild)專案檔中的目標呼叫它們。Regardless of whether you choose to deploy your web packages by running the .deploy.cmd file or by using MSDeploy.exe directly, you can parameterize your commands and call them from a target in a Microsoft Build Engine (MSBuild) project file.

在 Contact Manager 範例解決方案中,查看Publish檔案中的PublishWebPackages目標。In the Contact Manager sample solution, take a look at the PublishWebPackages target in the Publish.proj file. 這個目標會針對每個執行一次。部署名為PublishPackages的專案清單所識別的 .cmd檔案。This target runs once for each .deploy.cmd file identified by an item list named PublishPackages. 目標會使用屬性和專案中繼資料,為每個 . 部署 .cmd檔案建立一組完整的引數值,然後使用Exec工作來執行命令。The target uses properties and item metadata to build up a full set of argument values for each .deploy.cmd file and then uses the Exec task to run the command.

<Target Name="PublishWebPackages" Outputs="%(PublishPackages.Identity)">
  ...
  <PropertyGroup>
    <_WhatIfSwitch>/Y</_WhatIfSwitch>
    <_WhatIfSwitch Condition=" '$(_WhatIf)'=='true' ">/T</_WhatIfSwitch>
    <_Cmd>
      %(PublishPackages.FullPath) $(_WhatifSwitch) /M:$(MSDeployComputerName) 
      /U:$(MSDeployUsername) /P:$(Password) /A:$(MSDeployAuth) 
      %(PublishPackages.AdditionalMSDeployParameters)
    </_Cmd>
  </PropertyGroup>
  <Exec Command="$(_Cmd)"/>
</Target>

Note

如需範例方案中的專案檔模型,以及一般自訂專案檔案的簡介,請參閱瞭解專案檔和瞭解組建程式。For a broader overview of the project file model in the sample solution, and an introduction to custom project files in general, see Understanding the Project File and Understanding the Build Process.

端點考慮Endpoint Considerations

不論您是藉由執行 .deploy檔案或直接使用 msdeploy.exe 來部署 web 封裝,都必須為您的部署指定電腦名稱稱或服務端點。Regardless of whether you deploy your web package by running the .deploy.cmd file or by using MSDeploy.exe directly, you need to specify a computer name or a service endpoint for your deployment.

如果目的地 web 伺服器已設定為使用 Web Deploy 遠端代理程式服務進行部署,您可以指定目標服務 URL 作為目的地。If the destination web server is configured for deployment using the Web Deploy Remote Agent service, you specify the target service URL as your destination.

http://[server name]/MSDeployAgentService

或者,您可以單獨指定伺服器名稱作為目的地,Web Deploy 將會推斷遠端代理程式服務 URL。Alternatively, you can specify the server name alone as your destination, and Web Deploy will infer the remote agent service URL.

[server name]

如果目的地 web 伺服器已設定為使用 Web Deploy 處理常式進行部署,您必須指定 IIS Web 管理服務(WMSvc)的端點位址作為目的地。If the destination web server is configured for deployment using the Web Deploy Handler, you need to specify the endpoint address of the IIS Web Management Service (WMSvc) as your destination. 根據預設,這會採用下列格式:By default, this takes the form:

https://[server name]:8172/MSDeploy.axd

您可以使用 . deploy .cmd檔案或 msdeploy.exe 直接將目標設為這些端點的任何一個。You can target any of these endpoints using either the .deploy.cmd file or MSDeploy.exe directly. 不過,如果您想要以非系統管理員使用者的身分部署至 Web Deploy 處理常式(如設定 Web Deploy 發佈的 Web 服務器(Web Deploy 處理常式)中所述,您需要將查詢字串新增至服務端點位址。However, if you want to deploy to the Web Deploy Handler as a non-administrator user, as described in Configure a Web Server for Web Deploy Publishing (Web Deploy Handler), you need to add a query string to the service endpoint address.

https://[server name]:8172/MSDeploy.axd?site=[IIS website name]

這是因為非系統管理員的使用者沒有 IIS 的伺服器層級存取權;他或她只能存取特定的 IIS 網站。This is because the non-administrator user doesn't have server-level access to IIS; he or she only has access to a specific IIS website. 在撰寫本文時,由於 Web 發行管線(WPP)中的錯誤,您無法使用包含查詢字串的端點位址來執行 .deploy檔案。At the time of writing, due to a bug in the Web Publishing Pipeline (WPP), you can't run the .deploy.cmd file using an endpoint address that includes a query string. 在此案例中,您需要直接使用 Msdeploy.exe 來部署您的 web 封裝。In this scenario, you need to deploy your web package by using MSDeploy.exe directly.

Note

如需有關 Web Deploy 遠端代理程式服務和 Web Deploy 處理常式的詳細資訊,請參閱選擇正確的 Web 部署方法For more information on the Web Deploy Remote Agent service and the Web Deploy Handler, see Choosing the Right Approach to Web Deployment. 如需如何設定環境特定專案檔以部署至這些端點的指引,請參閱設定目標環境的部署屬性For guidance on how to configure your environment-specific project files to deploy to these endpoints, see Configure Deployment Properties for a Target Environment.

驗證考量Authentication Considerations

無論您是藉由執行 .deploy檔案或直接使用 msdeploy.exe 來部署 web 封裝,都必須指定驗證類型。Regardless of whether you deploy your web package by running the .deploy.cmd file or by using MSDeploy.exe directly, you need to specify an authentication type. Web Deploy 接受兩個可能的值: NTLMBasicWeb Deploy accepts two possible values: NTLM or Basic. 如果指定基本驗證,您也必須提供使用者名稱和密碼。If you specify basic authentication, you also need to provide a user name and password. 當您選取驗證類型時,需要留意的各種因素如下:There are various factors you need to be aware of when you select an authentication type:

  • 如果您要部署到 Web Deploy 遠端代理程式服務,則必須使用 NTLM 驗證。If you're deploying to the Web Deploy Remote Agent service, you must use NTLM authentication. 遠端代理程式服務不接受基本驗證認證。The remote agent service doesn't accept basic authentication credentials.
  • 如果您要部署到 Web Deploy 處理常式,可以使用 NTLM 或基本驗證。If you're deploying to the Web Deploy Handler, you can use either NTLM or basic authentication. 預設設定為 [基本驗證]。The default setting is basic authentication. 雖然基本驗證依賴以純文字傳送的使用者名稱和密碼,但您的認證會受到保護,因為 Web Deploy 處理常式一律使用 SSL 加密。Although basic authentication relies on user names and passwords being transmitted in plain text, your credentials are protected as the Web Deploy Handler always uses SSL encryption.
  • 如果您的網頁封裝包含資料庫,而 web 伺服器和資料庫伺服器是不同的電腦,由於ntlm 「雙躍點」的限制,您將無法使用 ntlm 驗證來部署資料庫。If your web package includes a database, and the web server and database server are separate machines, you won't be able to deploy the database using NTLM authentication due to the NTLM "double-hop" limitation. 您需要在部署連接字串中使用 SQL Server 認證,或提供基本驗證認證來 Web Deploy。You need to either use SQL Server credentials in your deployment connection string or supply basic authentication credentials to Web Deploy. 成員資格資料庫部署到企業環境中有更詳細的說明此問題。This issue is described in more detail in Deploying Membership Databases to Enterprise Environments.

結論Conclusion

本主題說明如何藉由執行 .deploy檔案或直接使用 msdeploy.exe 來部署 web 封裝。This topic described how you can deploy a web package either by running the .deploy.cmd file or by using MSDeploy.exe directly. 文中說明了每種方法的適當時機,並說明如何在較大的單一步驟或自動化的組建程式中,將部署命令參數化和執行。It explained when each approach might be appropriate, and it described how you can parameterize and run a deployment command as part of a larger single-step or automated build process.

進一步閱讀Further Reading

如需如何建立和參數化 web 部署套件的指引,請參閱建立和封裝 Web 應用程式專案和設定web 套件部署的參數For guidance on how to create and parameterize a web deployment package, see Building and Packaging Web Application Projects and Configuring Parameters for Web Package Deployment. 如需如何從 Team Foundation Server (TFS)實例建立及部署 web 封裝的指引,請參閱設定自動化 Web 部署的 Team Foundation ServerFor guidance on how to build and deploy web packages from a Team Foundation Server (TFS) instance, see Configuring Team Foundation Server for Automated Web Deployment. 如需如何自訂和疑難排解部署程式的相關資訊,請參閱從部署中排除檔案和資料夾For information on how to customize and troubleshoot the deployment process, see Excluding Files and Folders from Deployment.