forked from WilbertOnGithub/TFS2GIT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove-tfs-bindings.ps1
51 lines (47 loc) · 1.54 KB
/
remove-tfs-bindings.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
$folder = pwd;
#first clear the read-only flag from all files
get-childitem "$folder" -Recurse | % {
# Test for ReadOnly flag and remove if present
if ($_.attributes -band [system.IO.FileAttributes]::ReadOnly) {
$_.attributes = $_.attributes -bxor [system.IO.FileAttributes]::ReadOnly
}
}
#next delete all files that are *.suo, *.user, and *.*scc - we don't want thim in TFS
Get-ChildItem $folder *.suo -Recurse -Force | Remove-Item -Force
Get-ChildItem $folder *.*scc -Recurse -Force | Remove-Item -Force
Get-ChildItem $folder *.user -Recurse -Force | Remove-Item -Force
#next get all the .sln file - and remove the VSS binding information
Get-ChildItem $folder *.sln -Recurse | foreach {
$file = $_
echo "Opening $file"
$fileout = $file.FullName + ".new"
Set-Content $fileout $null
$switch=0
Get-Content $file.FullName | foreach {
if ($switch -eq 0) {
if ($_.Contains("GlobalSection(TeamFoundationVersionControl) = preSolution")) {
#we found the section to skip - so set the flag and don't copy the content
echo "Found TFS Section"
$switch=1
}
else {
#we haven't found it yet - so copy the content
Add-Content $fileout $_
}
}
elseif ($switch -eq 1) {
if ($_.Contains("EndGlobalSection")) {
#last line to skip - after it we start writing the content again
$switch=2
}
}
else {
#write remaining lines
Add-Content $fileout $_
}
}
#remove the original .sln and rename the new one
$newname = $file.Name
Remove-Item $file.FullName
Rename-Item $fileout -NewName $newname
}