diff --git a/build.psm1 b/build.psm1 index 01d8b4ded7..1b9bd8aef3 100644 --- a/build.psm1 +++ b/build.psm1 @@ -635,32 +635,41 @@ Fix steps: } # publish powershell.config.json - $config = @{} + $config = [ordered]@{} if ($Options.Runtime -like "*win*") { - # Execution Policy is only supported on Windows - $config = @{ "Microsoft.PowerShell:ExecutionPolicy" = "RemoteSigned"; - "WindowsPowerShellCompatibilityModuleDenyList" = @("PSScheduledJob", "BestPractices", "UpdateServices") - } + # Execution Policy and WinCompat feature are only supported on Windows. + $config.Add("Microsoft.PowerShell:ExecutionPolicy", "RemoteSigned") + $config.Add("WindowsPowerShellCompatibilityModuleDenyList", @("PSScheduledJob", "BestPractices", "UpdateServices")) } if (-not $SkipExperimentalFeatureGeneration -and (Test-IsPreview $psVersion) -and -not (Test-IsReleaseCandidate $psVersion) ) { - - $ExperimentalFeatureJsonFilePath = if ($Options.Runtime -like "*win*") { - "$PSScriptRoot/experimental-feature-windows.json" + if (-not $env:PS_RELEASE_BUILD -and -not $Runtime.Contains("arm") -and -not ($Runtime -like 'fxdependent*')) { + Write-Verbose "Build experimental feature list by running 'Get-ExperimentalFeature'" -Verbose + $json = & $publishPath\pwsh -noprofile -command { + $expFeatures = Get-ExperimentalFeature | ForEach-Object -MemberName Name + ConvertTo-Json $expFeatures + } } else { - "$PSScriptRoot/experimental-feature-linux.json" + Write-Verbose "Build experimental feature list by using the pre-generated JSON files" -Verbose + $ExperimentalFeatureJsonFilePath = if ($Options.Runtime -like "*win*") { + "$PSScriptRoot/experimental-feature-windows.json" + } else { + "$PSScriptRoot/experimental-feature-linux.json" + } + + if (-not (Test-Path $ExperimentalFeatureJsonFilePath)) { + throw "ExperimentalFeatureJsonFilePath: $ExperimentalFeatureJsonFilePath does not exist" + } + + $json = Get-Content -Raw $ExperimentalFeatureJsonFilePath } - if (-not (Test-Path $ExperimentalFeatureJsonFilePath)) { - throw "ExperimentalFeatureJsonFilePath: $ExperimentalFeatureJsonFilePath does not exist" - } + $config.Add('ExperimentalFeatures', [string[]]($json | ConvertFrom-Json)); - $json = Get-Content -Raw $ExperimentalFeatureJsonFilePath - $config += @{ ExperimentalFeatures = ([string[]] ($json | ConvertFrom-Json)) } } else { Write-Warning -Message "Experimental features are not enabled in powershell.config.json file" } diff --git a/tools/releaseBuild/azureDevOps/releaseBuild.yml b/tools/releaseBuild/azureDevOps/releaseBuild.yml index e21b4fe0c4..32f6bcca59 100644 --- a/tools/releaseBuild/azureDevOps/releaseBuild.yml +++ b/tools/releaseBuild/azureDevOps/releaseBuild.yml @@ -28,6 +28,8 @@ resources: ref: master variables: + - name: PS_RELEASE_BUILD + value: 1 - name: DOTNET_CLI_TELEMETRY_OPTOUT value: 1 - name: POWERSHELL_TELEMETRY_OPTOUT