我遇到了一个错误,我在TeamCity构建中运行Powershell脚本时感到困惑。该脚本来自名为PackageWeb的Nuget包。该脚本用于获取MSDeploy包并将其部署到远程计算机上运行的IIS实例。该脚本可以阅读here。我得到的错误如下:
"C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync
-source:archiveDir="C:\TeamCity\buildAgent\temp\buildTmp\App Name.csproj_zip" -
dest:auto,includeAcls='False',
ComputerName='mycomputer',Username=hurry,Password=up,AuthType='NTML'
-disableLink:AppPoolExtension
-disableLink:ContentExtension -disableLink:CertificateExtension
-setParamFile:"C:\TeamCity\buildAgent\temp\buildTmp\App Name.csproj_zip\SetParameters.xml" -whatif -
skip:objectName=dirPath,absolutePath="_Deploy_" -
skip:objectName=filePath,absolutePath=web\..*\.config -skip:objectName=dirPath,absolutePath=_Package
-skip:objectName=filePath,absolutePath=.*\.wpp\.targets$ -allowUntrusted -enableRule:DoNotDelete
The term 'C:\TeamCity\buildAgent\temp\buildTmp\App' is not recognized as the name
of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
第二行必须是罪魁祸首,“App Name”中的单词之间的空格可能是错误的,但我还没有找到一种方法可以正确地逃避这一点。 “App Name”来自msdeploy包的zip文件名(称为“App Name.csproj_zip”)。
为什么Powershell从TeamCity运行的任何想法都不允许在msdeploy路径中留出空间???
答案 0 :(得分:0)
我一直在搞乱Powershell + MSDeploy + TeamCity以及以下功能对我有用。请注意,参数{3}是MSDeploy(包含空格)的路径
function Deploy([string]$server, [string]$remotePath, [string]$localPath) {
$msdeploy = "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe";
cmd.exe /C $("`"{3}`" -verb:sync -source:contentPath=`"{0}`" -dest:computerName=`"{1}`",contentPath=`"{2}`" " -f $localPath, $server, $remotePath , $msdeploy )
}