我正在尝试调用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关键字。
我做错了什么,我如何才能纠正它?
我尝试使用以下解决方案
solution1
发布于 2016-03-02 19:49:01
我看不出你的脚本有什么问题,但是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 ' ')https://stackoverflow.com/questions/35724159
复制相似问题