powershell/ msbuild

I'm trying to run a Sync from MSBuild (From Powershell) that also includes Pre Sync Commands.

I am unable to get the commands right. I've tried multiple ways, but the final way I'm up to is :

[string[]]$msdeployArgs = @(
  "-verb:sync",
  "-preSync:runCommand='$preSyncCommand',waitInterval=30000",
  "-source:dirPath=$sourceFolder",
  "-dest:computerName=$serverName,userName=$username,password=$password,authType=basic,dirPath=$serviceFolder", 
  "-postSync:runCommand=$postSyncCommand,waitInterval=30000"
)

& "C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" $msdeployArgs

I get the following error.

Error: Unrecognized argument '"-preSync:runCommand='F:\\Projects\\Unleashed\\Release_Scripts\\WindowsServices\\deployTopShelfServicePreCommands.cmd Unleashed.Maintenance.JobScheduler C:\\MyCompany\\Services\\MyCompany.Maintenance.JobScheduler',waitInterval=30000"'. All arguments must begin with "-".

Note that after the PreSyncCommand, is params that I want to pass to the CMD file (For it to know where to uninstall the existing service from etc.

I've ran that params via EchoArgs.exe, and the args are fine.

If it matters (It might), I'm running the powershell script from TeamCity.

I've found the issue. As it turns out, it isn't powershell with the issue, but MSDeploy. MSDeploy as far as I can see does not allow you to pass batch files with parameters. Removing the parameters works fine (But then you need to hardcode them in your batch file, or work out some other way of generating the bat files on the fly).

暂无
暂无

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question Optionally pass argument to MSBuild from powershell Where does Powershell and PSake execute msbuild from? PowerShell exit code - Calling from MSBuild Access MSBuild from Post Build Powershell Script Changing MSBuild properties from Powershell script Execute powershell in x64 from MSBuild Line breaks invoking PowerShell from MSBuild How to invoke MSBuild from PowerShell using & operator? Configuration format easy to read from both MSBuild and PowerShell Powershell Pre-Build script failing from msbuild
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM