From bd8b0bd42163a9a6f3fc32001662d845b7f7fff0 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Wed, 12 Jun 2024 16:47:36 -0700 Subject: [PATCH] Create `powershell.config.json` for `PowerShell.Windows.x64` global tool (#23941) --- .pipelines/templates/windows-hosted-build.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.pipelines/templates/windows-hosted-build.yml b/.pipelines/templates/windows-hosted-build.yml index 6ecedc30f7..cdf639438f 100644 --- a/.pipelines/templates/windows-hosted-build.yml +++ b/.pipelines/templates/windows-hosted-build.yml @@ -287,6 +287,14 @@ jobs: # remove PDBs to reduce the size of the nupkg Remove-Item -Path "$outputPath\temp\tools\net9.0\any\*.pdb" -Recurse -Force + # create powershell.config.json + $config = [ordered]@{} + $config.Add("Microsoft.PowerShell:ExecutionPolicy", "RemoteSigned") + $config.Add("WindowsPowerShellCompatibilityModuleDenyList", @("PSScheduledJob", "BestPractices", "UpdateServices")) + + $configPublishPath = Join-Path "$outputPath" 'temp' 'tools' 'net8.0' 'any' "powershell.config.json" + Set-Content -Path $configPublishPath -Value ($config | ConvertTo-Json) -Force -ErrorAction Stop + Compress-Archive -Path "$outputPath\temp\*" -DestinationPath "$outputPath\$nupkgName" -Force Remove-Item -Path "$outputPath\temp" -Recurse -Force