Bumble
Bumble

Reputation: 557

Powershell Msdeploy command error

I am trying to invoke Msdeploy in powershell , which is part of a teamcity build task.

My script is like this below



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

while i run this i get following error , error stack follows

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

As error says i have included sync keyword already.

what i am doing wrong and how can i rectify it ?

i tried to use following solutions

solution1

stackoverflow post

Upvotes: 0

Views: 366

Answers (1)

chief7
chief7

Reputation: 14383

I don't see a problem in your script but PS can be particular.

Here is how the new ASP.NET 5 PS-based deployment executes MSDeploy.exe maybe this will work better for you:

    $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 ' ')

Upvotes: 1

Related Questions