2016-03-01 55 views
0

我想在powershell中調用Msdeploy,它是teamcity構建任務的一部分。Powershell Msdeploy命令錯誤

我的劇本是這樣的下面



    $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.

由於錯誤說我已經包括同步關鍵字。

我做錯了什麼,我該如何糾正它?

我試着用下面的方法解決

solution1

stackoverflow post

回答

1

我沒有看到一個問題,在您的腳本,但PS可以是特定的。

下面是新的基於PS ASP.NET 5部署執行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 ' ') 
+0

感謝Cheif7,管理部署包throuh蔚藍的PowerShell命令發佈,AzureWebSiteProject。 (避免MSDeploy) – Bumble

+1

很高興幫助。 – chief7