-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangeReferencePath.ps1
More file actions
90 lines (76 loc) · 3.19 KB
/
Copy pathchangeReferencePath.ps1
File metadata and controls
90 lines (76 loc) · 3.19 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# if ($references -ne $null)
# {
# # Write-Output $project.FullName | Format-Table -AutoSize
#
# foreach($reference in $references)
# {
# if($reference -ne $null -and $reference.HintPath -match "DropLocation")
# {
# $makeChekOut = $true
# $reference.HintPath = $reference.HintPath -replace "DropLocation", "DropLocation\Build"
# Write-Output "Reference: " $reference.HintPath | Format-Table
# }
# }
# }
#
# if ($outputpaths -ne $null)
# {
# foreach($outputpath in $outputpaths)
# {
# if($outputpath -ne $null -and $outputpath.OutputPath -match "DropLocation")
# {
# $makeChekOut = $true
# $outputpath.OutputPath = $outputpath.OutputPath -replace "DropLocation", "DropLocation\Build"
# Write-Output "output path: " $outputpath.OutputPath | Format-Table
# }
# }
# }
#
# enable the pssnapin for TFS
# Add-PSSnapin Microsoft.TeamFoundation.PowerShell
function Re-OrderImports
{
param([xml]$myProject)
#$xml = [xml](Get-Content $myProject)
#$xmlns = "http://schemas.microsoft.com/developer/msbuild/2003"
$xml = $myProject
$imports = $xml.Project.Import | Where-Object {($_.Project -Match "Rosen.props" -or $_.Project -Match "Microsoft.CSharp.targets")}
$webImports = $xml.Project.Import | Where-Object{($_.Project -Match "Microsoft.WebApplication.targets" )}
if($imports -ne $null)
{
$newImports = $imports | Sort-Object Project -Descending
$imports | foreach {$xml.Project.RemoveChild($_)} | Out-Null
$newImports | foreach{$xml.Project.InsertAfter($_, $xml.Project.LastChild)} |Out-Null
if($webImports -ne $null)
{
$webImports | foreach {$xml.Project.RemoveChild($_)} | Out-Null
$webImports | foreach{$xml.Project.InsertAfter($_, $xml.Project.LastChild)} |Out-Null
}
return $true
}
return $false
}
clear
$projects = Get-ChildItem -Include "*.csproj" -Path C:\T\aims\1Dev\services -Recurse #| Where-Object {($_.FullName -Match "Rosen.Clients.Infrastructure.Base")}
#copiar los archivos con otro nombre
foreach($project in $projects)
{
# $tf = &"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\tf.exe" checkout $project
# $tf | Out-null
# $project.Attributes = 'Normal'
$xml = [xml](Get-Content $project)
$xmlns = "http://schemas.microsoft.com/developer/msbuild/2003"
# $xml.Data.Course.Subject
#$references = $xml.Project.ItemGroup.Reference | where{($_.HintPath -ne $null )}
#$outputpaths = $xml.Project.PropertyGroup | where {($_.OutputPath -ne $null)}
#Write-Output $outputpaths | Format-Table -AutoSize
$makeChekOut = $false
$makeChekOut = Re-OrderImports $xml
if($makeChekOut -eq $true)
{
Add-TfsPendingChange -Edit -item $project.FullName -lock none | Out-Null
$project.Attributes = 'Normal'
$xml.Save($project.FullName)
Write-Output $project.FullName
}
}