1
votes

I set up TFS Deployer currenlty at work and have been tried to write a Powershell script for the deployment. I have been researched and read many posted questions and answers at StackoverFlow but I couldn't really making the script working yet.

So far, when I run the following PS on windows PowerShell ISE, it runs.

$envMsDeploy = $env:msdeploy
$DirMsDeploy = split-Path -Parent $envMsDeploy

# defined the current location to $DirMSDeploy = C:\Program Files\IIS\Microsoft Web Deploy V2
set-location $DirMsDeploy

$arg = @(
'-verb:sync';
'-source:contentPath=' + $buildDroppedLocation;
'-dest:contentPath=' + $destinationPath;
' -whatif > c:\temp\msdeploy.log'
)


$runMSDeploy = ($DirMsDeploy + "\Msdeploy.exe " + $arg)
$runMSDeploy | Out-file c:\temp\MsDeployTest.bat

I put the last sentence to confirm what gets saved $runMSDeploy. Now looks like $runMSDeploy saves what I want to put finally.

MSDeployTest.Bat contains C:\Program Files\IIS\Microsoft Web Deploy V2\Msdeploy.exe -verb:sync -source:contentPath=[[c:\source folder]] -dest:contentPath=[[Detination UNC path]] -whatif > c:\temp\msdeploy.log

This is where I'm stuck at right now. Because of the c:\Program files contains the empty folder, cmd doesn't run successfully rather giving me the error, "cmd.exe : 'C:\Program' is not recognized as an internal or external command"

If you have any suggestions or idea, please let me know.

thanks,

wanttogoshreddingeveryday

2
$envMsDeploy = $env:msdeploy <enter> $DirMsDeploy = split-Path -Parent $envMsDeploy <Enter> # defined the current location to C:\Program Files\IIS\Microsoft Web Deploy V2 <Enter> set-location $DirMsDeploy <enter> <enter> $arg = @( '-verb:sync'; '-source:contentPath=' + $buildDroppedLocation; '-dest:contentPath=' + $destinationPath; ' -whatif > c:\temp\msdeploy.log' ) <Enter> $runMSDeploy = ($DirMsDeploy + "\Msdeploy.exe " + $arg) <enter>wanttogoshreddingeveryday
#BEGIN $MsDeployDir = (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\MSDeploy).'(default)' $MsDeployExe = $MsDeployDir | Join-Path -ChildPath msdeploy.exe & cmd.exe /c $('" "{0}" -verb:sync -source:contentPath="{1}" -dest:contentPath="{2}" -whatif "' -f $MSDeployExe, $BuildDroppedLocation, $DestinationPath) #ENDwanttogoshreddingeveryday
Jason Stangroome who developed TFS Deployer helped me at here tfsdeployer.codeplex.com/discussions/251531wanttogoshreddingeveryday

2 Answers

0
votes

Here is a small example which start notepad.exe with a parametter

function F([string]$file)
 { 
    notepad.exe $file
 } 

 Clear-Host
 F "c:\Temp\fic.txt"

JP

0
votes

Try this gist. It should have everything you need to deploy via powershell https://gist.github.com/579086

It uses Psake, but it will work without it as well.