test-build-correctness.ps1 2.2 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
<#
    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"

function Get-PackagesPath {
    $packagesPath = $env:NUGET_PACKAGES
    if ($packagesPath -eq $null) {
        $packagesPath = join-path $env:UserProfile ".nuget\packages\"
    }

    return $packagesPath
}

27
pushd $sourcePath
28 29
try
{
J
Jared Parsons 已提交
30 31 32
    # Need to parse out the current NuGet package version of Structured Logger
    [xml]$deps = get-content (join-path $sourcePath "build\Targets\Dependencies.props")
    $structuredLoggerVersion = $deps.Project.PropertyGroup.MicrosoftBuildLoggingStructuredLoggerVersion
33 34 35 36
    $packagesPath = Get-PackagesPath
    $structuredLoggerPath = join-path $packagesPath "Microsoft.Build.Logging.StructuredLogger\$structuredLoggerVersion\lib\net46\StructuredLogger.dll"
    $logPath = join-path $binariesPath "build.xml"

J
Jared Parsons 已提交
37
    write-host "Building Roslyn.sln with logging support"
J
Jared Parsons 已提交
38
    & msbuild /v:m /m /logger:StructuredLogger`,$structuredLoggerPath`;$logPath /nodeReuse:false /p:DeployExtension=false Roslyn.sln
39 40 41 42 43 44 45 46 47 48
    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 $?) {
J
Jared Parsons 已提交
49
        write-host "See the README for more details on BuildBoss: $(join-path $sourcePath "src\Tools\BuildBoss\README.md")"
50 51 52 53 54 55 56 57 58 59 60 61
        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 ""
62

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