Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
small powershell script which allows you to quickly clean your repo during the migration
param([string]$targetPath)
$targetSearchPath = $targetPath+"\*"
remove-item $targetSearchPath -Recurse -include *.vspscc,*.vssscc -Verbose
$slnRegexPattern = 'GlobalSection\(TeamFoundationVersionControl\)[:\w\d\s\\.=\/{}-]*EndGlobalSection'
$slnFiles = get-childitem -Path $targetSearchPath -Recurse -Filter *.sln
foreach($slnFile in $slnFiles)
{
$content = get-content $slnFile.FullName -Raw
if($content -match $slnRegexPattern)
{
($content -replace $slnRegexPattern, '') | Out-File -FilePath $slnFile.FullName -Verbose -Encoding utf8;
}
}
$projRegexPattern = '[\t\r]*<Scc.*</Scc\w*>'
$projFiles = get-childitem -Path $targetSearchPath -Recurse -Filter *.*proj
foreach($projFile in $projFiles)
{
$content = Get-Content $projFile.FullName -Raw
if($content -match $projRegexPattern)
{
($content -replace $projRegexPattern, '') | Out-File -FilePath $projFile.FullName -Verbose -Encoding utf8;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment