From a5585609f85b4a853fd609bfb9025e5ded64782c Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Thu, 11 Jan 2024 19:47:55 +0100 Subject: [PATCH] Provide Windows entry point build scripts --- src/SourceBuild/content/build.cmd | 9 ++++ src/SourceBuild/content/eng/build.ps1 | 78 +++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 src/SourceBuild/content/build.cmd create mode 100644 src/SourceBuild/content/eng/build.ps1 diff --git a/src/SourceBuild/content/build.cmd b/src/SourceBuild/content/build.cmd new file mode 100644 index 000000000..c70d2b375 --- /dev/null +++ b/src/SourceBuild/content/build.cmd @@ -0,0 +1,9 @@ +@echo off +setlocal + +set _args=%* +if "%~1"=="-?" set _args=-help +if "%~1"=="/?" set _args=-help + +powershell -ExecutionPolicy ByPass -NoProfile -Command "& '%~dp0eng\build.ps1'" %_args% +exit /b %ERRORLEVEL% \ No newline at end of file diff --git a/src/SourceBuild/content/eng/build.ps1 b/src/SourceBuild/content/eng/build.ps1 new file mode 100644 index 000000000..4170f7bf3 --- /dev/null +++ b/src/SourceBuild/content/eng/build.ps1 @@ -0,0 +1,78 @@ +[CmdletBinding(PositionalBinding=$false)] +Param( + [string][Alias('c')]$configuration = "Release", + [switch] $clean, + [switch][Alias('bl')]$binaryLog, + [switch][Alias('nobl')]$excludeCIBinarylog, + [switch] $ci, + [switch] $prepareMachine, + [switch] $help, + [Parameter(ValueFromRemainingArguments=$true)][String[]]$properties +) + +function Get-Usage() { + Write-Host "Common settings:" + Write-Host " -configuration Build configuration: 'Debug' or 'Release' (short: -c). [Default: Release]" + Write-Host " -binaryLog Output binary log (short: -bl)" + Write-Host " -help Print help and exit" + Write-Host "" + + Write-Host "Actions:" + Write-Host " -clean Clean the solution" + Write-Host "" + + Write-Host "Advanced settings:" + Write-Host " -ci Set when running on CI server" + Write-Host " -excludeCIBinarylog Don't output binary log (short: -nobl)" + Write-Host " -prepareMachine Prepare machine for CI run, clean up processes after build" + Write-Host "" +} + +. $PSScriptRoot\common\tools.ps1 + +# Set the NUGET_PACKAGES dir so that we don't accidentally pull some packages from the global location, +# They should be pulled from the local feeds. +$env:NUGET_PACKAGES="$PSScriptRoot/.packages" + +function Build { + InitializeToolset + + $bl = if ($binaryLog) { '/bl:' + (Join-Path $LogDir 'Build.binlog') } else { '' } + + MSBuild "$PSScriptRoot\build.proj" ` + $bl ` + --tl:off ` + /p:Configuration=$configuration ` + @properties +} + +try { + if ($clean) { + if (Test-Path $ArtifactsDir) { + Remove-Item -Recurse -Force $ArtifactsDir + Write-Host 'Artifacts directory deleted.' + } + exit 0 + } + + if ($help -or (($null -ne $properties) -and ($properties.Contains('/help') -or $properties.Contains('/?')))) { + Print-Usage + exit 0 + } + + if ($ci) { + if (-not $excludeCIBinarylog) { + $binaryLog = $true + } + $nodeReuse = $false + } + + Build +} +catch { + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Category 'Build' -Message $_ + ExitWithExitCode 1 +} + +ExitWithExitCode 0