Scripts/Build.ps1


function BuildSingleProject([string]$projectPath, [string]$target)
{
    <#
    .SYNOPSIS
    Builds the given dotnet project without tracking down its dependencies.
    Target should be either "Build" or "Rebuild".
    #>


    if(-not (Test-Path "$projectPath"))
    {
        Write-Output "The project path is invalid."
        exit 1
    }
    if((IsVsDev) -eq $false)
    {
        CallVsDev "$VsVersion" *>$null
    }

    $arguments = "`"$projectPath`" /t:$target /p:RunCodeAnalysis=false;Configuration=Debug;Platform=x64;BuildProjectReferences=false;WarningLevel=0"    
    
    Write-Output "> msbuild $arguments"

    $info = New-Object System.Diagnostics.ProcessStartInfo
    $info.FileName = "msbuild"
    $info.Arguments = $arguments
    $info.RedirectStandardError = $false
    $info.RedirectStandardOutput = $false
    $info.UseShellExecute = $false
    $p = New-Object System.Diagnostics.Process
    $p.StartInfo = $info
    [void]$p.Start()
    $p.WaitForExit()
    $exitCode = $p.ExitCode
    Write-Output "MsBuild ExitCode: $exitCode"
}

function BuildDlcProxyGeneration([string]$localWorkspace)
{
<#
    .SYNOPSIS
    Builds the [DlcProxyGeneration] project.
    #>


    if(-not $localWorkspace)
    {
        $localWorkspace = $global:LocalWorkspace
    }

    $projectPath = "$localWorkspace\src\S7F\Tools\MsBuild\DlcProxyGeneration\DlcProxyGeneration.sln"

    if(-not (Test-Path "$projectPath"))
    {
        Write-Output "The project path is invalid."
        exit 1
    }
    if((IsVsDev) -eq $false)
    {
        CallVsDev "$VsVersion" *>$null
    }
    & msbuild "$projectPath" /t:Build /p:Configuration=Debug`;Platform=x64`;BuildProjectReferences=false`;WarningLevel=0
}

function BuildTestExecutionButlerFilterSafety([string]$localWorkspace)
{
<#
    .SYNOPSIS
    Builds the [Test.Execution.Butler.Filter.Safety] project.
    #>


    if(-not $localWorkspace)
    {
        $localWorkspace = $global:LocalWorkspace
    }

    $projectPath = "$localWorkspace\src\S7F\Tools\TEB\Test.Execution.Butler.Filter.Safety\Test.Execution.Butler.Filter.Safety.csproj"

    if(-not (Test-Path "$projectPath"))
    {
        Write-Output "The project path is invalid."
        exit 1
    }
    if((IsVsDev) -eq $false)
    {
        CallVsDev "$VsVersion" *>$null
    }
    & msbuild "$projectPath" /t:Build /p:Configuration=Debug`;Platform=x64`;BuildProjectReferences=false`;WarningLevel=0
}