0

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

1 Answer 1

1

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 ' ')
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Cheif7 , managed to deploy package throuh azure powershell command Publish-AzureWebSiteProject. (avoided MSDeploy)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.