diff --git a/build.psm1 b/build.psm1 index 3b808c562cf..4e1fd0f3f9a 100644 --- a/build.psm1 +++ b/build.psm1 @@ -159,6 +159,7 @@ function Get-EnvironmentInformation } if ($environment.IsLinux) { + $environment += @{ 'OSArchitecture' = [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture } $LinuxInfo = Get-Content /etc/os-release -Raw | ConvertFrom-StringData $lsb_release = Get-Command lsb_release -Type Application -ErrorAction Ignore | Select-Object -First 1 if ($lsb_release) { @@ -455,6 +456,9 @@ Fix steps: if ($Options.Runtime -like 'win*' -or ($Options.Runtime -like 'fxdependent*' -and $environment.IsWindows)) { $Arguments += "/property:IsWindows=true" + if(!$environment.IsWindows) { + $Arguments += "/property:EnableWindowsTargeting=true" + } } else { $Arguments += "/property:IsWindows=false" @@ -648,7 +652,7 @@ Fix steps: (Test-IsPreview $psVersion) -and -not (Test-IsReleaseCandidate $psVersion) ) { - if (-not $env:PS_RELEASE_BUILD -and -not $Runtime.Contains("arm") -and -not ($Runtime -like 'fxdependent*')) { + if ((Test-ShouldGenerateExperimentalFeatures -Runtime $Options.Runtime)) { Write-Verbose "Build experimental feature list by running 'Get-ExperimentalFeature'" -Verbose $json = & $publishPath\pwsh -noprofile -command { $expFeatures = Get-ExperimentalFeature | ForEach-Object -MemberName Name @@ -697,6 +701,45 @@ Fix steps: } } +function Test-ShouldGenerateExperimentalFeatures +{ + param( + [Parameter(Mandatory)] + $Runtime + ) + + if ($env:PS_RELEASE_BUILD) { + return $false + } + + if ($Runtime -like 'fxdependent*') { + return $false + } + + $runtimePattern = 'unknown-' + if ($environment.IsWindows) { + $runtimePattern = '^win.*-' + } + + if ($environment.IsMacOS) { + $runtimePattern = '^osx.*-' + } + + if ($environment.IsLinux) { + $runtimePattern = '^linux.*-' + } + + $runtimePattern += $environment.OSArchitecture.ToString() + Write-Verbose "runtime pattern check: $Runtime -match $runtimePattern" -Verbose + if ($Runtime -match $runtimePattern) { + Write-Verbose "Generating experimental feature list" -Verbose + return $true + } + + Write-Verbose "Skipping generating experimental feature list" -Verbose + return $false +} + function Restore-PSPackage { [CmdletBinding()]