From 26624c30afb8d8950d892b849b03d0a3237c5ecb Mon Sep 17 00:00:00 2001 From: bschnurr Date: Thu, 22 Jan 2026 16:21:52 -0800 Subject: [PATCH] append proposed flags to publish --- .vscode/settings.json | 4 ++- build/templates/publish-extension.yml | 7 ++++++ build/templates/publish.yml | 35 ++++++++++++++++++++++++--- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 0de09696..269b37e5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -22,4 +22,6 @@ }, "git.branchProtection": ["main"], "git.branchRandomName.enable": true, -} \ No newline at end of file + "python-envs.defaultEnvManager": "ms-python.python:system", + "python-envs.pythonProjects": [] +} diff --git a/build/templates/publish-extension.yml b/build/templates/publish-extension.yml index b1cc7c92..22745256 100644 --- a/build/templates/publish-extension.yml +++ b/build/templates/publish-extension.yml @@ -213,6 +213,13 @@ jobs: } $package = Get-Content $packageJsonPath -Raw | ConvertFrom-Json + $enabledApiProposals = @() + if ($null -ne $package.enabledApiProposals) { + $enabledApiProposals = @($package.enabledApiProposals) + } + $enabledApiProposalsJson = ($enabledApiProposals | ConvertTo-Json -Compress) + Write-Host "##vso[task.setvariable variable=EnabledApiProposalsJson]$enabledApiProposalsJson" + Write-Host ("enabledApiProposals: " + ($(if ($enabledApiProposals.Count -gt 0) { $enabledApiProposals -join ', ' } else { '' }))) Write-Host "##vso[task.setvariable variable=publisher;isOutput=true]$($package.publisher)" Write-Host "##vso[task.setvariable variable=version;isOutput=true]$($package.version)" name: SetPublisherAndVersion diff --git a/build/templates/publish.yml b/build/templates/publish.yml index def1f746..dd6395ac 100644 --- a/build/templates/publish.yml +++ b/build/templates/publish.yml @@ -100,14 +100,41 @@ steps: Write-Host "Listing platform folder contents:" Get-ChildItem $root | Select-Object Name,Length | Format-Table -AutoSize + # If the extension uses proposed APIs, vsce requires explicitly allowing them. + # We expect EnabledApiProposalsJson to be set by an earlier step (e.g. publish-extension.yml). + $allowProposedApisArgs = @() + $enabledApiProposalsJson = "$(EnabledApiProposalsJson)" + if (-not $enabledApiProposalsJson -or ($enabledApiProposalsJson -match '^\$\(')) { + Write-Host "EnabledApiProposalsJson is not set; publishing without --allow-proposed-apis." + } else { + try { + $enabledApiProposals = @($enabledApiProposalsJson | ConvertFrom-Json) + if ($enabledApiProposals.Count -gt 0) { + Write-Host ("enabledApiProposals (from EnabledApiProposalsJson): " + ($enabledApiProposals -join ', ')) + $allowProposedApisArgs = @('--allow-proposed-apis') + @($enabledApiProposals) + } else { + Write-Host "EnabledApiProposalsJson parsed as empty; no proposed API allowlist flags needed." + } + } catch { + Write-Host "EnabledApiProposalsJson was set but could not be parsed; publishing without --allow-proposed-apis." + } + } + if ('${{ parameters.preRelease }}' -eq 'True') { Write-Host 'Publishing as pre-release' - Write-Host "Executing: npx @vscode/vsce@latest publish --pat *** --packagePath $vsixPath --manifestPath $manifestPath --signaturePath $signaturePath --pre-release" - npx @vscode/vsce@latest publish --pat $aadToken --packagePath $vsixPath --manifestPath $manifestPath --signaturePath $signaturePath --pre-release + $allowProposedApisDisplay = ($allowProposedApisArgs -join ' ') + $displayCmd = "Executing: npx @vscode/vsce@latest publish --pat *** --packagePath $vsixPath --manifestPath $manifestPath --signaturePath $signaturePath" + if ($allowProposedApisDisplay) { $displayCmd += " $allowProposedApisDisplay" } + $displayCmd += ' --pre-release' + Write-Host $displayCmd + npx @vscode/vsce@latest publish --pat $aadToken --packagePath $vsixPath --manifestPath $manifestPath --signaturePath $signaturePath $allowProposedApisArgs --pre-release } else { Write-Host 'Publishing as stable release' - Write-Host "Executing: npx @vscode/vsce@latest publish --pat *** --packagePath $vsixPath --manifestPath $manifestPath --signaturePath $signaturePath" - npx @vscode/vsce@latest publish --pat $aadToken --packagePath $vsixPath --manifestPath $manifestPath --signaturePath $signaturePath + $allowProposedApisDisplay = ($allowProposedApisArgs -join ' ') + $displayCmd = "Executing: npx @vscode/vsce@latest publish --pat *** --packagePath $vsixPath --manifestPath $manifestPath --signaturePath $signaturePath" + if ($allowProposedApisDisplay) { $displayCmd += " $allowProposedApisDisplay" } + Write-Host $displayCmd + npx @vscode/vsce@latest publish --pat $aadToken --packagePath $vsixPath --manifestPath $manifestPath --signaturePath $signaturePath $allowProposedApisArgs } if ($LASTEXITCODE -ne 0) {