diff --git a/eng/build.ps1 b/eng/build.ps1 index a874e5e828cb6..db18267f33e1c 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -147,6 +147,26 @@ if ($os) { $os = $os.ToLowerInvariant() } +if ($os -eq "browser") { + # override default arch for Browser, we only support wasm + $arch = "wasm" + + if ($msbuild -eq $True) { + Write-Error "Using the -msbuild option isn't supported when building for Browser on Windows, we need need ninja for Emscripten." + exit 1 + } +} + +if ($os -eq "wasi") { + # override default arch for wasi, we only support wasm + $arch = "wasm" + + if ($msbuild -eq $True) { + Write-Error "Using the -msbuild option isn't supported when building for WASI on Windows, we need ninja for WASI-SDK." + exit 1 + } +} + if ($vs) { $archToOpen = $arch[0] $configToOpen = $configuration[0] @@ -247,6 +267,16 @@ if ($vs) { $env:RUNTIMEFLAVOR=$runtimeFlavor } + # Respect the TargetOS variable for building non AnyOS libraries + if ($os) { + $env:TARGETOS=$os + } + + # Respect the TargetArchitecture variable for building non AnyCPU libraries + if ($arch) { + $env:TARGETARCHITECTURE=$arch + } + # Launch Visual Studio with the locally defined environment variables ."$vs" @@ -301,26 +331,6 @@ $env:DOTNETSDK_ALLOW_TARGETING_PACK_CACHING=0 $failedBuilds = @() -if ($os -eq "browser") { - # override default arch for Browser, we only support wasm - $arch = "wasm" - - if ($msbuild -eq $True) { - Write-Error "Using the -msbuild option isn't supported when building for Browser on Windows, we need need ninja for Emscripten." - exit 1 - } -} - -if ($os -eq "wasi") { - # override default arch for wasi, we only support wasm - $arch = "wasm" - - if ($msbuild -eq $True) { - Write-Error "Using the -msbuild option isn't supported when building for WASI on Windows, we need ninja for WASI-SDK." - exit 1 - } -} - foreach ($config in $configuration) { $argumentsWithConfig = $arguments + " -configuration $((Get-Culture).TextInfo.ToTitleCase($config))"; foreach ($singleArch in $arch) {