Created
June 22, 2010 04:54
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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