forked from dotnet/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetlist.ps1
34 lines (26 loc) · 1.43 KB
/
getlist.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
## Script that gets the list of projects that need to be built.
## This script it used by the VSTS build agents.
## Author: Den Delimarsky (dendeli)
## Last Modified: 8/12/2016
$homePath = (Get-Item -Path ".\" -Verbose).FullName
$corePath = $homePath + "\samples\core"
[System.Collections.ArrayList]$globalProjects = Get-ChildItem $corePath -Recurse | where {$_.Name -eq "global.json"}
[System.Collections.ArrayList]$singleProjects = Get-ChildItem $corePath -Recurse | where {$_.Name -eq "project.json" }
$itemsToRemove = New-Object "System.Collections.Generic.List[System.Object]"
foreach($item in $singleProjects){
foreach ($blockedItem in $globalProjects){
if ($item.Directory.ToString().StartsWith($blockedItem.Directory.ToString() + "\")){
$itemsToRemove.Add($item)
break
}
}
}
Write-Host "Single projects before cleanup: " $singleProjects.Count
foreach($target in $itemsToRemove)
{
Write-Host "Removing " $target.Directory " from the list of single projects."
$singleProjects.Remove($target)
}
Write-Host "Single projects after cleanup: " $singleProjects.Count
($singleProjects | select-object FullName | ConvertTo-Csv -NoTypeInformation | % { $_ -replace '"', ""} ) | Select-Object -Skip 1 | Set-Content -Path single.projects
($globalProjects | select-object FullName | ConvertTo-Csv -NoTypeInformation | % { $_ -replace '"', ""} ) | Select-Object -Skip 1 | Set-Content -Path global.projects