-
Notifications
You must be signed in to change notification settings - Fork 7
/
Get-TestProjects.ps1
49 lines (43 loc) · 1.67 KB
/
Get-TestProjects.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
<#
.SYNOPSIS
Gets the paths to all the csproj files that are MSTest based unit test projects.
#>
function Get-TestProjects
{
[CmdletBinding()]
Param(
[string] $SolutionFilePath
)
Write-Verbose "Using solution $SolutionFilePath"
$allProjects = Get-ProjectFiles -SolutionFilePath $SolutionFilePath
$projects = @()
foreach ($projectFullPath in $allProjects)
{
if (-Not (Test-Path $projectFullPath))
{
Write-Verbose "Project path doesnt have a file: '$projectFullPath'"
continue
}
if ($projectFullPath.IndexOf("UnitTest", [System.StringComparison]::OrdinalIgnoreCase) -ge 0)
{
Write-Verbose "Project item detected in the UnitTest subfolder"
$projects += $projectFullPath
Write-Output $projectFullPath
Write-Verbose "Project added to the list. There are $($projects.Length) so far"
continue
}
$projFileInfo = New-Object System.IO.FileInfo -ArgumentList $projectFullPath
$projectName = $projFileInfo.BaseName
if ($projectName.EndsWith("Tests", [System.StringComparison]::OrdinalIgnoreCase))
{
Write-Verbose "Project item detected in by name suffix"
$projects += $projectFullPath
Write-Output $projectFullPath
Write-Verbose "Project added to the list. There are $($projects.Length) so far"
continue
}
# add in opening the csproj file and sniffing the project type guids and other properties
# $projFile = [xml](Get-Content -Path $projectFullPath)
}
#return $projects
}