Skip to content

Commit 5072f53

Browse files
committed
Added template parameter enabledApiProposalsJson.
Added env: EnabledApiProposalsJson: ${{ parameters.enabledApiProposalsJson }} on the PowerShell@2 step. Script continues to read $env:EnabledApiProposalsJson (safe for JSON with quotes). publish-extension.yml Wired it up: enabledApiProposalsJson: $(EnabledApiProposalsJson) when calling the publish template. This should fully eliminate the PowerShell parser failure you hit while still allowing the --allow-proposed-apis ... list to be applied when present.
1 parent 9e0e66c commit 5072f53

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

build/templates/publish-extension.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ jobs:
239239
azureSubscription: ${{ parameters.azureSubscription }}
240240
buildPlatforms: ${{ parameters.buildPlatforms }}
241241
manifestName: ${{ parameters.manifestName }}
242+
enabledApiProposalsJson: $(EnabledApiProposalsJson)
242243
signatureName: ${{ parameters.signatureName }}
243244
publishFolder: ${{ parameters.publishFolder }}
244245
preRelease: ${{ parameters.preRelease }}

build/templates/publish.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ parameters:
4242
- name: preRelease
4343
type: boolean
4444
default: false
45+
- name: enabledApiProposalsJson
46+
type: string
47+
default: ''
4548

4649
steps:
4750
# Node & vsce expected to be prepared by parent pipeline; omit local installation.
@@ -68,6 +71,8 @@ steps:
6871
- ${{ each platform in parameters.buildPlatforms }}:
6972
- task: PowerShell@2
7073
displayName: "Publish extension (${{ coalesce(platform.vsceTarget, 'universal') }})"
74+
env:
75+
EnabledApiProposalsJson: ${{ parameters.enabledApiProposalsJson }}
7176
inputs:
7277
targetType: inline
7378
script: |
@@ -103,8 +108,8 @@ steps:
103108
# If the extension uses proposed APIs, vsce requires explicitly allowing them.
104109
# We expect EnabledApiProposalsJson to be set by an earlier step (e.g. publish-extension.yml).
105110
$allowProposedApisArgs = @()
106-
$enabledApiProposalsJson = "$(EnabledApiProposalsJson)"
107-
if (-not $enabledApiProposalsJson -or ($enabledApiProposalsJson -match '^\$\(')) {
111+
$enabledApiProposalsJson = $env:EnabledApiProposalsJson
112+
if ([string]::IsNullOrWhiteSpace($enabledApiProposalsJson)) {
108113
Write-Host "EnabledApiProposalsJson is not set; publishing without --allow-proposed-apis."
109114
} else {
110115
try {
@@ -120,17 +125,17 @@ steps:
120125
}
121126
}
122127
128+
$allowProposedApisDisplay = ($allowProposedApisArgs -join ' ')
129+
123130
if ('${{ parameters.preRelease }}' -eq 'True') {
124131
Write-Host 'Publishing as pre-release'
125-
$allowProposedApisDisplay = ($allowProposedApisArgs -join ' ')
126132
$displayCmd = "Executing: npx @vscode/vsce@latest publish --pat *** --packagePath $vsixPath --manifestPath $manifestPath --signaturePath $signaturePath"
127133
if ($allowProposedApisDisplay) { $displayCmd += " $allowProposedApisDisplay" }
128134
$displayCmd += ' --pre-release'
129135
Write-Host $displayCmd
130136
npx @vscode/vsce@latest publish --pat $aadToken --packagePath $vsixPath --manifestPath $manifestPath --signaturePath $signaturePath $allowProposedApisArgs --pre-release
131137
} else {
132138
Write-Host 'Publishing as stable release'
133-
$allowProposedApisDisplay = ($allowProposedApisArgs -join ' ')
134139
$displayCmd = "Executing: npx @vscode/vsce@latest publish --pat *** --packagePath $vsixPath --manifestPath $manifestPath --signaturePath $signaturePath"
135140
if ($allowProposedApisDisplay) { $displayCmd += " $allowProposedApisDisplay" }
136141
Write-Host $displayCmd

0 commit comments

Comments
 (0)