summaryrefslogtreecommitdiff
path: root/.github/scripts/Build-ChangedProjects.ps1
blob: a13e3501e32e801f10c31d3831767b5c86de794a (plain)
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
param (
    [array]$ChangedFiles
)

$root = (Get-Location).Path

# To include in CI gate
$projectSet = @{}
foreach ($file in $ChangedFiles)
{
    if (-not (Test-Path $file)) {
        Write-Output "`u{2754} Changed file $file cannot be found"
        continue
    }
    $dir = (Get-Item $file).DirectoryName
    while ((-not ($slnItems = (Get-ChildItem $dir '*.sln'))) -and ($dir -ne $root))
    {
        $dir = (Get-Item $dir).Parent.FullName
    }
    if ($dir -eq $root)
    {
        Write-Output "`u{2754} Changed file $file does not match a project."
        continue
    }
    $projectName = $dir.Replace($root, '').Trim('\').Replace('\', '.').ToLower()
    Write-Output "`u{1F50E} Found project [$projectName] at $dir from changed file $file"
    if (-not ($projectSet.ContainsKey($projectName)))
    {
        $projectSet[$projectName] = $dir
    }
}

.\Build-ProjectSet -ProjectSet $projectSet