summaryrefslogtreecommitdiff
path: root/Build-ProjectSet.ps1
blob: 2557b5b988d6410af0b61a0529808cbeeb969c26 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
param(
    [hashtable]$ProjectSet,
    [string]$Configuration = $env:Configuration,
    [string]$Platform = $env:Platform
)

if ([string]::IsNullOrEmpty($Configuration))
{
    $Configuration = "Debug"
}

if ([string]::IsNullOrEmpty($Platform))
{
    $Platform = "x64"
}

$oldPreference = $ErrorActionPreference
$ErrorActionPreference = "stop"
try
{
    # Check that msbuild can be called before trying anything.
    Get-Command "msbuild" | Out-Null
}
catch
{
    Write-Host "`u{274C} msbuild cannot be called from current environment. Check that msbuild is set in current path (for example, that it is called from a Visual Studio developer command)."
    Write-Error "msbuild cannot be called from current environment."
    exit 1
}
finally
{
    $ErrorActionPreference = $oldPreference
}


$exclusionsSet = @{}
$failSet = @()
Import-Csv 'exclusions.csv' | ForEach-Object {
    $exclusionsSet[$_.Path.Replace($root, '').Trim('\').Replace('\', '.').ToLower()] = $_.Reason
}

$ProjectSet.GetEnumerator() | ForEach-Object {
    $projectName = $_.Key
    if ($exclusionsSet.ContainsKey($projectName))
    {
        Write-Output "[$projectName] `u{23E9} Excluded and skipped. Reason: $($exclusionsSet[$projectName])"
        return;
    }
    $directory = $_.Value
    .\Build-Project -Directory $directory -ProjectName $ProjectName -Configuration $Configuration -Platform $Platform
    if ($LASTEXITCODE -ne 0)
    {
        $failSet += $ProjectName
    }
}

if ($failSet.Count -gt 0)
{
    Write-Output "Some projects were built with errors:"
    foreach ($failedProject in $failSet)
    {
        Write-Output "$failedProject"
    }
    Write-Error "Some projects were built with errors."
}