Skip to content

Commit

Permalink
Avoid depending on the pre-generated experimental feature list in pri…
Browse files Browse the repository at this point in the history
…vate and CI builds (#18484)
  • Loading branch information
daxian-dbw committed Nov 10, 2022
1 parent 21a7ab7 commit 1809328
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
37 changes: 23 additions & 14 deletions build.psm1
Expand Up @@ -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"
}

if (-not (Test-Path $ExperimentalFeatureJsonFilePath)) {
throw "ExperimentalFeatureJsonFilePath: $ExperimentalFeatureJsonFilePath does not exist"
$json = Get-Content -Raw $ExperimentalFeatureJsonFilePath
}

$json = Get-Content -Raw $ExperimentalFeatureJsonFilePath
$config += @{ ExperimentalFeatures = ([string[]] ($json | ConvertFrom-Json)) }
$config.Add('ExperimentalFeatures', [string[]]($json | ConvertFrom-Json));

} else {
Write-Warning -Message "Experimental features are not enabled in powershell.config.json file"
}
Expand Down
2 changes: 2 additions & 0 deletions tools/releaseBuild/azureDevOps/releaseBuild.yml
Expand Up @@ -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
Expand Down

0 comments on commit 1809328

Please sign in to comment.