From eb8855eb540c89b17957d7f4a93d9ccea753abd6 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Mon, 17 Aug 2026 11:48:44 -0400 Subject: [PATCH 1/2] first test with pnpm registry var --- docker/Dockerfile | 11 +++++++++++ eng/tsp-core/pipelines/publish.yml | 3 +++ .../http-client-csharp/eng/pipeline/publish.yml | 8 ++++++-- .../eng/scripts/RegenPreview.ps1 | 3 ++- .../eng/scripts/Submit-AzureSdkForNetPr.ps1 | 16 ++++++++++------ 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 37071f7b30b..cc3457e3822 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -3,6 +3,13 @@ # -------------------------------- # cspell:ignore tdnf FROM mcr.microsoft.com/devcontainers/javascript-node:24 AS builder + +# Optional: Override npm registry for CFS compliance. +# pnpm 11+ requires PNPM_CONFIG_REGISTRY (ignores NPM_CONFIG_REGISTRY). +ARG NPM_REGISTRY= +ENV PNPM_CONFIG_REGISTRY=${NPM_REGISTRY} +ENV NPM_CONFIG_REGISTRY=${NPM_REGISTRY} + COPY . /app # Upgrade all packages per https://eng.ms/docs/more/containers-secure-supply-chain/updating. @@ -24,6 +31,10 @@ RUN pnpm pack # -------------------------------- FROM mcr.microsoft.com/azurelinux/base/nodejs:24 +# Inherit registry setting for final stage +ARG NPM_REGISTRY= +ENV NPM_CONFIG_REGISTRY=${NPM_REGISTRY} + COPY --from=builder /app/packages/compiler/*.tgz /tmp/compiler.tgz RUN npm install -g /tmp/compiler.tgz && rm /tmp/compiler.tgz diff --git a/eng/tsp-core/pipelines/publish.yml b/eng/tsp-core/pipelines/publish.yml index f3898f7cae3..7b866a770b9 100644 --- a/eng/tsp-core/pipelines/publish.yml +++ b/eng/tsp-core/pipelines/publish.yml @@ -86,6 +86,8 @@ extends: displayName: Build and publish variables: imageName: "azsdkengsys.azurecr.io/typespec" + # Default to Azure SDK public feed; override with pipeline variable for CFS compliance + npmRegistry: $[coalesce(variables['NPM_REGISTRY'], 'https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry/')] pool: name: $(LINUXPOOL) image: $(LINUXVMIMAGE) @@ -100,6 +102,7 @@ extends: - script: | docker build -f ./docker/Dockerfile \ + --build-arg NPM_REGISTRY="$(npmRegistry)" \ -t $(imageName):latest \ . displayName: "Build" diff --git a/packages/http-client-csharp/eng/pipeline/publish.yml b/packages/http-client-csharp/eng/pipeline/publish.yml index 8e480d9943f..af73766a640 100644 --- a/packages/http-client-csharp/eng/pipeline/publish.yml +++ b/packages/http-client-csharp/eng/pipeline/publish.yml @@ -122,7 +122,9 @@ extends: # to avoid running out of disk space on the root partition during generation TMPDIR: $(Agent.TempDirectory) NUGET_PACKAGES: $(Agent.TempDirectory)/nuget + # Set cache for both npm and pnpm (pnpm 11+ ignores npm_config_* prefix) npm_config_cache: $(Agent.TempDirectory)/npm-cache + pnpm_config_store-dir: $(Agent.TempDirectory)/pnpm-store steps: - checkout: self @@ -198,10 +200,12 @@ extends: -PackageJsonPath '$(Build.SourcesDirectory)/packages/http-client-csharp/package.json' - pwsh: | + # Set force for both npm and pnpm (pnpm 11+ ignores npm_config_* prefix) Write-Host "##vso[task.setvariable variable=npm_config_force]true" + Write-Host "##vso[task.setvariable variable=pnpm_config_force]true" Write-Host "##vso[task.setvariable variable=TSPCLIENT_FORCE_INSTALL]true" - Write-Host "Set npm --force and TSPCLIENT_FORCE_INSTALL for TypeSpec Next" - displayName: Configure npm for TypeSpec Next + Write-Host "Set npm/pnpm --force and TSPCLIENT_FORCE_INSTALL for TypeSpec Next" + displayName: Configure npm/pnpm for TypeSpec Next condition: ${{ parameters.UseTypeSpecNext }} - task: UseDotNet@2 diff --git a/packages/http-client-csharp/eng/scripts/RegenPreview.ps1 b/packages/http-client-csharp/eng/scripts/RegenPreview.ps1 index 5ab1b823fa5..1cdab7ac7da 100644 --- a/packages/http-client-csharp/eng/scripts/RegenPreview.ps1 +++ b/packages/http-client-csharp/eng/scripts/RegenPreview.ps1 @@ -1059,7 +1059,8 @@ try { Write-Host "Configuring npm registry for tsp-client (temporary .env)..." -ForegroundColor Gray $sdkEnvFile = Join-Path $sdkRepoPath ".env" $originalSdkEnv = if (Test-Path $sdkEnvFile) { Get-Content $sdkEnvFile -Raw } else { $null } - Set-Content $sdkEnvFile "npm_config_registry=$artifactFeedRegistry`n" -Encoding utf8 -NoNewline + # Set both npm and pnpm registry env vars (pnpm 11+ ignores npm_config_* prefix) + Set-Content $sdkEnvFile "npm_config_registry=$artifactFeedRegistry`npnpm_config_registry=$artifactFeedRegistry`n" -Encoding utf8 -NoNewline Write-Host " Wrote $sdkEnvFile" -ForegroundColor Green Write-Host "" diff --git a/packages/http-client-csharp/eng/scripts/Submit-AzureSdkForNetPr.ps1 b/packages/http-client-csharp/eng/scripts/Submit-AzureSdkForNetPr.ps1 index 3e2b94ff1a2..dbfcd46688a 100755 --- a/packages/http-client-csharp/eng/scripts/Submit-AzureSdkForNetPr.ps1 +++ b/packages/http-client-csharp/eng/scripts/Submit-AzureSdkForNetPr.ps1 @@ -399,17 +399,20 @@ try { $configFilesOutputDir = Join-Path $tempDir "eng" $emitterPackageJsonPath = Join-Path $configFilesOutputDir "http-client-csharp-emitter-package.json" - # Set NPM_CONFIG_USERCONFIG to point to our .npmrc so tsp-client's internal npm install - # can resolve packages from Azure Artifacts. tsp-client creates a temp directory for - # npm install, so a project-level .npmrc in the eng directory won't be found. + # Set NPM_CONFIG_USERCONFIG and PNPM_CONFIG_USERCONFIG to point to our .npmrc so + # tsp-client's internal npm/pnpm install can resolve packages from Azure Artifacts. + # tsp-client creates a temp directory for install, so a project-level .npmrc won't be found. + # Note: pnpm 11+ ignores npm_config_* prefix, so we set both. $sourceNpmrcPath = Join-Path $PSScriptRoot "../../.npmrc" $previousNpmConfigUserconfig = $env:NPM_CONFIG_USERCONFIG - + $previousPnpmConfigUserconfig = $env:PNPM_CONFIG_USERCONFIG + if (Test-Path $sourceNpmrcPath) { $resolvedNpmrcPath = (Resolve-Path $sourceNpmrcPath).Path - Write-Host "Setting NPM_CONFIG_USERCONFIG to use .npmrc for tsp-client package resolution..." + Write-Host "Setting NPM_CONFIG_USERCONFIG and PNPM_CONFIG_USERCONFIG to use .npmrc for tsp-client package resolution..." Write-Host " Source .npmrc: $resolvedNpmrcPath" $env:NPM_CONFIG_USERCONFIG = $resolvedNpmrcPath + $env:PNPM_CONFIG_USERCONFIG = $resolvedNpmrcPath Write-Host "npm registry for tsp-client:" npm config get registry @@ -445,8 +448,9 @@ try { } Write-Host "Successfully generated emitter-package.json files" } finally { - # Restore previous NPM_CONFIG_USERCONFIG + # Restore previous NPM_CONFIG_USERCONFIG and PNPM_CONFIG_USERCONFIG $env:NPM_CONFIG_USERCONFIG = $previousNpmConfigUserconfig + $env:PNPM_CONFIG_USERCONFIG = $previousPnpmConfigUserconfig } } else { Write-Warning "TypeSpecSourcePackageJsonPath not provided or file doesn't exist. Skipping emitter-package.json generation." From 8446caffce5a792723f637270f3c51094484e721 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Mon, 17 Aug 2026 13:14:20 -0400 Subject: [PATCH 2/2] fix: address copilot review comments - Use underscore in pnpm_config_store_dir (not hyphen) - Default NPM_REGISTRY to https://registry.npmjs.org/ instead of empty --- docker/Dockerfile | 4 ++-- packages/http-client-csharp/eng/pipeline/publish.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index cc3457e3822..7c6c6047f48 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -6,7 +6,7 @@ FROM mcr.microsoft.com/devcontainers/javascript-node:24 AS builder # Optional: Override npm registry for CFS compliance. # pnpm 11+ requires PNPM_CONFIG_REGISTRY (ignores NPM_CONFIG_REGISTRY). -ARG NPM_REGISTRY= +ARG NPM_REGISTRY=https://registry.npmjs.org/ ENV PNPM_CONFIG_REGISTRY=${NPM_REGISTRY} ENV NPM_CONFIG_REGISTRY=${NPM_REGISTRY} @@ -32,7 +32,7 @@ RUN pnpm pack FROM mcr.microsoft.com/azurelinux/base/nodejs:24 # Inherit registry setting for final stage -ARG NPM_REGISTRY= +ARG NPM_REGISTRY=https://registry.npmjs.org/ ENV NPM_CONFIG_REGISTRY=${NPM_REGISTRY} COPY --from=builder /app/packages/compiler/*.tgz /tmp/compiler.tgz diff --git a/packages/http-client-csharp/eng/pipeline/publish.yml b/packages/http-client-csharp/eng/pipeline/publish.yml index af73766a640..5691fb0ddab 100644 --- a/packages/http-client-csharp/eng/pipeline/publish.yml +++ b/packages/http-client-csharp/eng/pipeline/publish.yml @@ -124,7 +124,7 @@ extends: NUGET_PACKAGES: $(Agent.TempDirectory)/nuget # Set cache for both npm and pnpm (pnpm 11+ ignores npm_config_* prefix) npm_config_cache: $(Agent.TempDirectory)/npm-cache - pnpm_config_store-dir: $(Agent.TempDirectory)/pnpm-store + pnpm_config_store_dir: $(Agent.TempDirectory)/pnpm-store steps: - checkout: self