Powershell Msdeploy命令错误

时间:2016-03-01 13:24:45

标签: powershell deployment teamcity msdeploy

我试图在powershell中调用Msdeploy,这是teamcity构建任务的一部分。

我的脚本如下所示



    $folderName = "packageTmp"
    $packagePath = (gci -path %teamcity.build.checkoutDir%\extract -filter $foldername -Recurse | Select-Object -Expand FullName) |Out-String

    $azureSite ="%azureSite%"
    $azurePublishUrl = "%azurePublishUrl%"
    $azureUsername ="%azureUsername%"
    $azurePassword = "%azurePassword%"

    $localPath =$packagePath 
    $server ="https://$azurePublishUrl/msdeploy.axd?site=$azureSite,UserName=$azureUsername,Password=$azurePassword,AuthType=Basic"
    $remotePath="%azureSite%"

    $env:Path += ";C:\Program Files\IIS\Microsoft Web Deploy V3"

    function PushToTarget() {
    param([string]$server, [string]$remotePath, [string]$localPath)
          cmd.exe /C $("msdeploy.exe -verb:sync -source:contentPath=`"{0}`" -dest:computerName=`"{1}`",contentPath=`"{2}`" -whatif" -f $localPath, $server, $remotePath )
    }
    echo "Server: " $server
    echo "remote path: " $remotePath
    echo "local path: " $localPath

    PushToTarget "$server" "$remotePath" "$localPath"

当我运行这个时,我得到以下错误,错误堆栈如下

Error: A '-dest' argument must be specified with the 'sync' verb.

由于错误说我已经包含了sync关键字。

我做错了什么,我该如何纠正呢?

我尝试使用以下解决方案

redis pipelining

solution1

1 个答案:

答案 0 :(得分:1)

我在脚本中看不到问题,但PS可能是特别的。

以下是新的基于ASP.NET 5 PS的部署如何执行MSDeploy.exe,这可能对您更有效:

    $webrootOutputFolder = (get-item (Join-Path $packOutput $webroot)).FullName
    $publishArgs = @()
    $publishArgs += ('-source:IisApp=''{0}''' -f "$webrootOutputFolder")
    $publishArgs += ('-dest:IisApp=''{0}'',ComputerName=''{1}'',UserName=''{2}'',Password=''{3}'',IncludeAcls=''False'',AuthType=''Basic''{4}' -f 
                            $publishProperties['DeployIisAppPath'],
                            (Get-MSDeployFullUrlFor -msdeployServiceUrl $publishProperties['MSDeployServiceURL']),
                            $publishProperties['UserName'],
                            $publishPwd,
                            $sharedArgs.DestFragment)
    $publishArgs += '-verb:sync'
    $publishArgs += '-enableLink:contentLibExtension'
    $publishArgs += $sharedArgs.ExtraArgs

    $command = '"{0}" {1}' -f (Get-MSDeploy),($publishArgs -join ' ')

    if (! [String]::IsNullOrEmpty($publishPwd)) {
    $command.Replace($publishPwd,'{PASSWORD-REMOVED-FROM-LOG}') | Print-CommandString
    }
    Execute-Command -exePath (Get-MSDeploy) -arguments ($publishArgs -join ' ')