Skip to content

Commit 1809328

Browse files
authored
Avoid depending on the pre-generated experimental feature list in private and CI builds (PowerShell#18484)
1 parent 21a7ab7 commit 1809328

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

build.psm1

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -635,32 +635,41 @@ Fix steps:
635635
}
636636

637637
# publish powershell.config.json
638-
$config = @{}
638+
$config = [ordered]@{}
639639

640640
if ($Options.Runtime -like "*win*") {
641-
# Execution Policy is only supported on Windows
642-
$config = @{ "Microsoft.PowerShell:ExecutionPolicy" = "RemoteSigned";
643-
"WindowsPowerShellCompatibilityModuleDenyList" = @("PSScheduledJob", "BestPractices", "UpdateServices")
644-
}
641+
# Execution Policy and WinCompat feature are only supported on Windows.
642+
$config.Add("Microsoft.PowerShell:ExecutionPolicy", "RemoteSigned")
643+
$config.Add("WindowsPowerShellCompatibilityModuleDenyList", @("PSScheduledJob", "BestPractices", "UpdateServices"))
645644
}
646645

647646
if (-not $SkipExperimentalFeatureGeneration -and
648647
(Test-IsPreview $psVersion) -and
649648
-not (Test-IsReleaseCandidate $psVersion)
650649
) {
651-
652-
$ExperimentalFeatureJsonFilePath = if ($Options.Runtime -like "*win*") {
653-
"$PSScriptRoot/experimental-feature-windows.json"
650+
if (-not $env:PS_RELEASE_BUILD -and -not $Runtime.Contains("arm") -and -not ($Runtime -like 'fxdependent*')) {
651+
Write-Verbose "Build experimental feature list by running 'Get-ExperimentalFeature'" -Verbose
652+
$json = & $publishPath\pwsh -noprofile -command {
653+
$expFeatures = Get-ExperimentalFeature | ForEach-Object -MemberName Name
654+
ConvertTo-Json $expFeatures
655+
}
654656
} else {
655-
"$PSScriptRoot/experimental-feature-linux.json"
656-
}
657+
Write-Verbose "Build experimental feature list by using the pre-generated JSON files" -Verbose
658+
$ExperimentalFeatureJsonFilePath = if ($Options.Runtime -like "*win*") {
659+
"$PSScriptRoot/experimental-feature-windows.json"
660+
} else {
661+
"$PSScriptRoot/experimental-feature-linux.json"
662+
}
663+
664+
if (-not (Test-Path $ExperimentalFeatureJsonFilePath)) {
665+
throw "ExperimentalFeatureJsonFilePath: $ExperimentalFeatureJsonFilePath does not exist"
666+
}
657667

658-
if (-not (Test-Path $ExperimentalFeatureJsonFilePath)) {
659-
throw "ExperimentalFeatureJsonFilePath: $ExperimentalFeatureJsonFilePath does not exist"
668+
$json = Get-Content -Raw $ExperimentalFeatureJsonFilePath
660669
}
661670

662-
$json = Get-Content -Raw $ExperimentalFeatureJsonFilePath
663-
$config += @{ ExperimentalFeatures = ([string[]] ($json | ConvertFrom-Json)) }
671+
$config.Add('ExperimentalFeatures', [string[]]($json | ConvertFrom-Json));
672+
664673
} else {
665674
Write-Warning -Message "Experimental features are not enabled in powershell.config.json file"
666675
}

tools/releaseBuild/azureDevOps/releaseBuild.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ resources:
2828
ref: master
2929

3030
variables:
31+
- name: PS_RELEASE_BUILD
32+
value: 1
3133
- name: DOTNET_CLI_TELEMETRY_OPTOUT
3234
value: 1
3335
- name: POWERSHELL_TELEMETRY_OPTOUT

0 commit comments

Comments
 (0)