使用 msdeploy.exe 将文件夹部署到远程站点

using msdeploy.exe to deploy folder to remote site

我正在尝试为 msdeploy 找到正确的参数。 我有一个包含我要部署的 Web 内容的文件夹。

"C:\Program Files (x86)\IIS\Microsoft Web Deploy V3"\msdeploy.exe -verb:sync -source:contentPath="c:\work\WebPackage" -dest:contentPath="Default Web Site",computername="http://10.7.5.93",username='\localuser',password=aPassword

我收到此错误:

Error Code: ERROR_DESTINATION_NOT_REACHABLE
More Information: Could not connect to the remote computer ("10.7.5.93"). On the remote computer, make sure that Web Deploy is installed and that the required process ("Web Deployment Agent Service") is started.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_DESTINATION_NOT_REACHABLE.
Error: Unable to connect to the remote server
Error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 10.7.5.93:80
Error count: 1.

无法找出正确的语法。我可以使用此发布文件从 VS 进行部署:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>MSDeploy</WebPublishMethod>
    <ADUsesOwinOrOpenIdConnect>False</ADUsesOwinOrOpenIdConnect>
    <LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish>https://kitostest.miracle.dk</SiteUrlToLaunchAfterPublish>
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <MSDeployServiceURL>http://10.7.4.93</MSDeployServiceURL>
    <DeployIisAppPath>Default Web Site</DeployIisAppPath>
    <RemoteSitePhysicalPath />
    <SkipExtraFilesOnServer>False</SkipExtraFilesOnServer>
    <MSDeployPublishMethod>RemoteAgent</MSDeployPublishMethod>
    <EnableMSDeployBackup>True</EnableMSDeployBackup>
    <UserName>\deploy</UserName>
    <_SavePWD>True</_SavePWD>
    <PrecompileBeforePublish>True</PrecompileBeforePublish>
    <EnableUpdateable>True</EnableUpdateable>
    <DebugSymbols>False</DebugSymbols>
    <WDPMergeOption>DonotMerge</WDPMergeOption>
    <PublishDatabaseSettings>
      <Objects xmlns="">
        <ObjectGroup Name="KitosContext" Order="1" Enabled="False">
          <Destination Path="" />
          <Object Type="DbCodeFirst">
            <Source Path="DBMigration" DbContext="Infrastructure.DataAccess.KitosContext, Infrastructure.DataAccess" MigrationConfiguration="Infrastructure.DataAccess.Migrations.Configuration, Infrastructure.DataAccess" Origin="Configuration" />
          </Object>
        </ObjectGroup>
      </Objects>
    </PublishDatabaseSettings>
  </PropertyGroup>
  <ItemGroup>
    <MSDeployParameterValue Include="$(DeployParameterPrefix)KitosContext-Web.config Connection String" />
  </ItemGroup>
</Project>

并截取了部署参数的屏幕截图:

所以我需要找到一种方法将参数映射到 msdeploy。

这是我上次尝试的结果:

"C:\Program Files (x86)\IIS\Microsoft Web Deploy V3"\msdeploy.exe -whatif -verb:sync -source:contentPath="C:\work\WebPackage" -dest:contentPath='M:\Website',ComputerName="http://10.7.5.93/msdeploy.axd?site=Default Web Site",UserName='\ALocalUser',Password='MyPassWord',AuthType='Basic'

语法取自文章 How to publish the contents of a folder with msdeploy.exe contentPath

的语法

我成功了!!!在进行 Web 部署时,我使用 fiddler 监视 visual studio。它称我的网站为 site/MSDEPLOYAGENTSERVICE 而不是 site/msdeploy.axd。我不是在 Web 服务器上安装 msdeploy 的人,但如果我 read the manual 那么我可以避免 5 个小时的挫败感。

好像没有"Default web site"?尝试添加您发布到的网站名称:

msdeploy.exe -verb:sync -source:contentPath="..\WebPackage" -dest:auto,computername="http://10.7.5.93/msdeploy.axd?site=name_of_your_site",username=aUserName,password=aPassword 

取决于内容的创建方式,您可能需要对 msdeploy 行进行其他更改,但我会先尝试一下。