Skip to content

Commit

Permalink
Don't assume first argument in build.ps1 is subset (#97330)
Browse files Browse the repository at this point in the history
* Don't assume first argument in build.ps1 is subset

We assumed the first argument to the build script is the subset, but that doesn't work if you have `build.cmd /p:SomeProperty=value` like we have in the VMR.
Instead do what build.sh does and check whether the first argument looks like a valid subset string and only use it in that case.

Fixes dotnet/source-build#3790

* Update eng/build.ps1

Co-authored-by: Juan Hoyos <19413848+hoyosjs@users.noreply.github.com>

---------

Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>
Co-authored-by: Juan Hoyos <19413848+hoyosjs@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 22, 2024
1 parent ccdaf39 commit 971ebdb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Param(
[string]$testscope,
[switch]$testnobuild,
[ValidateSet("x86","x64","arm","arm64","wasm")][string[]][Alias('a')]$arch = @([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant()),
[Parameter(Position=0)][string][Alias('s')]$subset,
[string][Alias('s')]$subset,
[ValidateSet("Debug","Release","Checked")][string][Alias('rc')]$runtimeConfiguration,
[ValidateSet("Debug","Release")][string][Alias('lc')]$librariesConfiguration,
[ValidateSet("CoreCLR","Mono")][string][Alias('rf')]$runtimeFlavor,
Expand Down Expand Up @@ -130,6 +130,13 @@ if ($help) {
exit 0
}

# check the first argument if subset is not explicitly passed in
if (-not $PSBoundParameters.ContainsKey("subset") -and $properties.Length -gt 0 -and $properties[0] -match '^[a-zA-Z\.\+]+$') {
$subset = $properties[0]
$PSBoundParameters.Add("subset", $subset)
$properties = $properties | Select-Object -Skip 1
}

if ($subset -eq 'help') {
Invoke-Expression "& `"$PSScriptRoot/common/build.ps1`" -restore -build /p:subset=help /clp:nosummary"
exit 0
Expand Down

0 comments on commit 971ebdb

Please sign in to comment.