Created
September 22, 2010 07:16
-
-
Save tathamoddie/591285 to your computer and use it in GitHub Desktop.
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 () | |
$ErrorActionPreference = "Stop" | |
Set-PSDebug -Strict | |
$PSScriptFilePath = (Get-Item $MyInvocation.MyCommand.Path).FullName | |
$PSScriptRoot = Split-Path $PSScriptFilePath -Parent | |
try | |
{ | |
[Reflection.Assembly]::Load('Microsoft.TeamFoundation.VersionControl.Client, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') | Out-Null | |
} | |
catch | |
{ | |
throw 'TFS assembly could not be found. Ensure Team Explorer 2008 is installed.' | |
} | |
$WorkstationType = [Microsoft.TeamFoundation.VersionControl.Client.Workstation] | |
$SourceRoot = Join-Path $PSScriptRoot -ChildPath MasterPages\App\MasterPages\Base | |
$DomainsRoot = Join-Path $PSScriptRoot -ChildPath ..\..\Domains | |
"Source of truth: $SourceRoot" | |
$SourceMasters = Get-ChildItem -Path $SourceRoot -Filter *.master | | |
Where-Object { $_.IsReadOnly -eq $false } | |
if ($SourceMasters -eq $null) { | |
Write-Warning "None of the source master files are editable. (That is, they are all read only.) Only master files that are editable (and thus checked out) will be published." | |
} else { | |
"Found source masters: $SourceMasters" | |
Get-ChildItem -Path $DomainsRoot -Include $SourceMasters -Recurse | | |
ForEach-Object { | |
$SourcePath = Join-Path $SourceRoot -ChildPath $_.Name | |
$WorkspaceInfo = $WorkstationType::Current.GetLocalWorkspaceInfo($_) | |
$Collection = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($WorkspaceInfo.ServerUri) | |
$Workspace = $WorkspaceInfo.GetWorkspace($Collection) | |
"Checking out $_" | |
$Workspace.PendEdit($_) | |
"Updating $_" | |
Copy-Item -Path $SourcePath -Destination $_ -Force | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment