-
Notifications
You must be signed in to change notification settings - Fork 7
/
Get-ProjectFiles.ps1
53 lines (44 loc) · 1.46 KB
/
Get-ProjectFiles.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
52
53
<#
.SYNOPSIS
Gets all the project file paths for a solution
#>
function Get-ProjectFiles
{
[CmdletBinding()]
Param(
[string] $SolutionFilePath
)
Write-Verbose "Using solution $SolutionFilePath"
$slnFileContent = Get-Content $SolutionFilePath
$slnFileFolder = Split-Path $SolutionFilePath -Parent
$projects = @()
$lineNumber = 0
foreach ($line in $slnFileContent)
{
$lineNumber++
if ($line.StartsWith("Project", [System.StringComparison]::OrdinalIgnoreCase) -eq $false)
{
continue
}
Write-Verbose "Project file detected on line $lineNumber"
$lineSplits = $line.Split(",")
$projectRelativePath = $lineSplits[1].Replace("`"", "").Trim()
Write-Verbose "Project relative path $projectRelativePath"
if ($projectRelativePath.EndsWith("proj", [System.StringComparison]::OrdinalIgnoreCase) -eq $false)
{
Write-Verbose "Project item is not actually a proj file"
continue
}
$projectFullPath = Join-Path -Path $slnFileFolder -ChildPath $projectRelativePath
if (Test-Path $projectFullPath)
{
$projects += $projectFullPath
Write-Verbose "Project added to the list. There are $($projects.Length) so far"
}
else
{
Write-Verbose "Project path doesnt have a file: '$projectFullPath'"
}
}
return $projects
}