Skip to content

Instantly share code, notes, and snippets.

@tathamoddie
Created June 22, 2010 04:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tathamoddie/448023 to your computer and use it in GitHub Desktop.
Save tathamoddie/448023 to your computer and use it in GitHub Desktop.
Copies /Static/Base/ to /Static/v1234/ where 1234 is derived from the TFS version number
#requires -Version 2
[CmdletBinding()]
param (
$VersionIdentifier
)
$ErrorActionPreference = "Stop"
Set-PSDebug -Strict
$PSScriptFilePath = (Get-Item $MyInvocation.MyCommand.Path).FullName
$PSScriptRoot = Split-Path $PSScriptFilePath -Parent
$StaticRoot = Split-Path $PSScriptRoot -Parent
if ($VersionIdentifier -eq $null) {
Write-Verbose "No version identifier was supplied as an argument to this script so it will be determined automatically via TFS."
$TfsSnapin = Get-PSSnapin | Where-Object { $_.Name -eq 'Microsoft.TeamFoundation.PowerShell' }
if (-not $TfsSnapin) {
Add-PSSnapin Microsoft.TeamFoundation.PowerShell
}
$LatestChangesetId = (Get-TfsItemHistory -HistoryItem . -Recurse -StopAfter 1).ChangesetId;
$VersionIdentifier = "v" + $LatestChangesetId
if (-not $TfsSnapin) {
Remove-PSSnapin Microsoft.TeamFoundation.PowerShell
}
}
Write-Verbose "Using version identifier '$VersionIdentifier'."
$BaseRoot = Join-Path $StaticRoot -ChildPath Base # eg /Static/Base/
$VersionedRoot = Join-Path $StaticRoot -ChildPath $VersionIdentifier # eg /Static/v1234/
if (Test-Path $VersionedRoot -PathType Container) {
Remove-Item $VersionedRoot -Force -Recurse
}
Copy-Item $BaseRoot -Destination $VersionedRoot -Recurse
Set-Content (Join-Path $StaticRoot -ChildPath ActiveVersion.config) -Value $VersionIdentifier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment