0

I'm getting an error I'm baffled by when running a Powershell script in a TeamCity build. The script comes from a Nuget package called PackageWeb. The script is meant to take a MSDeploy package and deploy it to an instance of IIS running on a remote machine. The script can be read here. The error I get is the following:

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

The second line has to be the culprit, and the space between words in "App Name" is probably at fault, but I haven't found a way to escape this properly. The "App Name" is gotten from the zip file name of the msdeploy package (it's called "App Name.csproj_zip").

Any idea why Powershell run from TeamCity doesn't allow for a space in the path to msdeploy???

Torfi
  • 911
  • 1
  • 9
  • 13
  • 1
    Might be related: http://stackoverflow.com/questions/3499699/how-do-you-call-msdeploy-from-powershell-when-the-parameters-have-spaces/12813048#12813048 – David Brabant Jan 19 '15 at 15:26
  • Thanks David, yeah, I tried most of the things mentioned there, but no luck. – Torfi Jan 21 '15 at 13:11

1 Answers1

0

I have been messing with Powershell+MSDeploy+TeamCity and following function works for me. Note that parameter {3} is the path to MSDeploy ( which contains spaces)

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 )
    }
Illuminati
  • 4,539
  • 2
  • 35
  • 55