Skip to content

Instantly share code, notes, and snippets.

@baywet
Last active April 21, 2024 21:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save baywet/bcbed5e52c59f4201e7c to your computer and use it in GitHub Desktop.
Save baywet/bcbed5e52c59f4201e7c to your computer and use it in GitHub Desktop.
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