-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage_csproj.ps1
40 lines (33 loc) · 1.6 KB
/
manage_csproj.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
###############################################################################
#
# Functions to extract information from csproj files
#
###############################################################################
function GetHintPaths {
param(
[string] $CsProjFile = 'C:\src\trunk\ICTEAM.Solution\ICTEAM.Project1\ICTEAM.Project1.csproj' # serves as default value
)
[xml] $Xml = Get-Content $CsProjFile
$NsMgr = New-Object System.Xml.XmlNamespaceManager($Xml.NameTable)
$NsMgr.AddNamespace("ns", "http://schemas.microsoft.com/developer/msbuild/2003")
$Xml.SelectNodes("//ns:HintPath", $NsMgr) |% { New-Object PSObject -Property @{CsProjFile="$CsProjFile";HintPath=$_.InnerText} }
}
function GetProjectReferences {
param (
[string] $CsProjFile = 'C:\src\trunk\ICTEAM.Solution\ICTEAM.Project1\ICTEAM.Project1.csproj' # serves as default value
)
[xml] $Xml = Get-Content $CsProjFile
$Ns = New-Object System.Xml.XmlNamespaceManager($Xml.NameTable)
$Ns.AddNamespace("ns", "http://schemas.microsoft.com/developer/msbuild/2003")
$Xml.SelectNodes("//ns:ProjectReference", $Ns) |
ForEach-Object { $_.GetAttribute("Include") } |
% { New-Object PSObject -Property @{CsProjFile="$CsProjFile";ReferencedProject="$_"} }
}
function GetExternalProjectReferences {
param (
[string] $CsProjFile = 'C:\src\trunk\ICTEAM.Solution\ICTEAM.Project1\ICTEAM.Project1.csproj', # serves as default value
[string] $ProjectReferencesFilter = '..\..\*'
)
GetProjectReferences -CsProjFile "$CsProjFile" |
Where-Object { $_.ReferencedProject -like $ProjectReferencesFilter }
}