Skip to content

Instantly share code, notes, and snippets.

@baywet
Last active July 17, 2020 13:40
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
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