This code copies files to our Test server and places the executable on a file share for the tester to access. I'm new to Powershell, so I'm sure I'm not doing this in the most efficient way. Any criticisms would be appreciated.
# the destination that we are copying TO.
$codeToDeploy = "\\deployment_server\App-Shares\Developer_Area\Code to Deploy\";
# all the local folders we'll need
$myProjectFolder = "C:\MTS\ProjectFolder\Project\";
$myLocalOurProjectName = ($myProjectFolder + "OurProjectName\bin\Debug\");
$myLocalLauncher = ($myProjectFolder + "OurProjectName_Launcher\bin\Debug\");
$myLocalWcfService = ($myProjectFolder + "ProjectWCFService\bin\");
$myLocalWebsite = ($myProjectFolder + "MTSWebsite\bin\");
#----------------------------------------------------------------
# 1. prep the "code to deploy" folder on the server to receive files
#----------------------------------------------------------------
# set our current folder
Set-Location $codeToDeploy
# create the name of the new top level folder with today's date
$datedFolderName = "MM " + (get-date -Format "yyyy-MM-dd") + "\";
# create the date-named folder - overwrite if it already exists
New-Item $datedFolderName -ItemType directory -Force;
# set our current folder to the date-named folder
Set-Location $datedFolderName;
# create the sub folders
New-Item "OurProjectName Client" -ItemType directory -Force;
New-item "OurProjectName Launcher" -ItemType directory -Force;
New-item "ProjectWCFService\front end" -ItemType directory -Force;
New-item "Website\front end" -ItemType directory -Force;
#----------------------------------------------------------------
# 2. copy all the files from local debug to the target folders
#----------------------------------------------------------------
# copy to the MM Client folder
$destination = ($codeToDeploy + $datedFolderName + "OurProjectName Client\");
Set-Location $myLocalOurProjectName
Copy-Item *.dll,OurProjectName.exe $destination -Force;
# copy to the Launcher Folder
$destination = ($codeToDeploy + $datedFolderName + "OurProjectName Launcher\");
Set-Location $myLocalLauncher;
Copy-Item OurProjectName_Launcher.exe $destination -Force;
# copy to the Service Folder
$destination = ($codeToDeploy + $datedFolderName + "ProjectWCFService\");
Set-Location $myLocalWcfService;
Copy-Item *.dll $destination -Force;
Set-Location -Path ..
Copy-Item AllService.svc -Destination ($destination + "front end\") -Force;
# copy to the Website Folder
$destination = ($codeToDeploy + $datedFolderName + "Website\");
$frontEnd = ($destination + "front end\")
Set-Location $myLocalWebsite;
Copy-Item *.dll $destination -Force;
Set-Location -Path ..
Copy-Item *.aspx,*.master,CSS,SiteImages $frontEnd -Recurse -Force;
#----------------------------------------------------------------
# 3. copy all the files from local debug to the server's
# "client install\binaries" location for serving up to the launcher
#----------------------------------------------------------------
# copy to the MM Client folder
$destination = "\\app-ttps2-tst\App-Shares\Project\Client Install\Binaries\OurProjectName\";
Set-Location $myLocalOurProjectName
Copy-Item *.dll,OurProjectName.exe -Destination $destination -Force;
#----------------------------------------------------------------
# 4. copy all the files from local debug to the UI Testing location
#----------------------------------------------------------------
$folders = Get-ChildItem "\\nw\data\TnFS\Project\ProjectFolder\UI TESTING\MM *" | Sort-Object
#save the latest config file for later
#$latestConfigFile = $folders | Select-Object -Last | Get-ChildItem OurProjectName.exe.config
# copy to the MM Client folder
$destination = "\\nw\data\TnFS\Project\ProjectFolder\UI TESTING\" + $datedFolderName;
New-Item $destination -ItemType directory -Force;
Set-Location $myLocalOurProjectName
Copy-Item *.dll,OurProjectName.exe -Destination $destination -Force;