【问题标题】:Powershell Msdeploy command errorPowershell Msdeploy 命令错误
【发布时间】:2016-06-13 22:40:19
【问题描述】:

我正在尝试在 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.

正如错误所说,我已经包含了同步关键字。

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

我尝试使用以下解决方案

solution1

stackoverflow post

【问题讨论】:

    标签: powershell deployment teamcity msdeploy


    【解决方案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 ' ')
    

    【讨论】:

    • 感谢 Cheif7,设法通过 azure powershell 命令 Publish-AzureWebSiteProject 部署包。 (避免 MSDeploy)
    猜你喜欢
    • 2017-04-20
    • 2021-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    • 2010-10-10
    • 1970-01-01
    相关资源
    最近更新 更多