test-build-correctness.ps1 1.9 KB
Newer Older
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
<#
    This script drives the Jenkins verification that our build is correct.  In particular: 

        - Our build has no double writes
        - Our project.json files are consistent
        - our build files are well structured
        - Our solution states are consistent

#>

Param(
    [string]$sourcePath = $null,
    [string]$binariesPath = $null
)
set-strictmode -version 2.0
$ErrorActionPreference="Stop"

# TODO: unify with locate-vs.ps1
function Get-PackagesPath {
    $packagesPath = $env:NUGET_PACKAGES
    if ($packagesPath -eq $null) {
        $packagesPath = join-path $env:UserProfile ".nuget\packages\"
    }

    return $packagesPath
}

28
pushd $sourcePath
29 30
try
{
31

32 33 34 35 36 37 38 39 40 41
    # TODO: RepoUtil needs to generate a powershell file that can be imported for 
    # values like this.
    $structuredLoggerVersion = "1.0.58"
    $packagesPath = Get-PackagesPath

    write-host "Building Roslyn.sln with logging support"

    $structuredLoggerPath = join-path $packagesPath "Microsoft.Build.Logging.StructuredLogger\$structuredLoggerVersion\lib\net46\StructuredLogger.dll"
    $logPath = join-path $binariesPath "build.xml"

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
    & msbuild /v:m /m /logger:StructuredLogger`,$structuredLoggerPath`;$logPath Roslyn.sln
    if (-not $?) {
        exit 1
    }
    write-host ""

    # Verify the state of our various build artifacts
    write-host "Running BuildBoss"
    $buildBossPath = join-path $binariesPath "Exes\BuildBoss\BuildBoss.exe"
    & $buildBossPath Roslyn.sln Compilers.sln src\Samples\Samples.sln CrossPlatform.sln "build\Targets" $logPath
    if (-not $?) {
        exit 1
    }
    write-host ""

    # Verify the state of our project.jsons
    write-host "Running RepoUtil"
    $repoUtilPath = join-path $binariesPath "Exes\RepoUtil\RepoUtil.exe"
    & $repoUtilPath verify
    if (-not $?) {
        exit 1
    }
    write-host ""
65

66
    exit 0
67 68 69 70 71 72
}
catch [exception]
{
    write-host $_.Exception
    exit -1
}
73 74 75 76
finally
{
    popd
}