From 09a921586b0955120f2c70d0f1c807ab32a2b76d Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Wed, 4 Mar 2026 13:40:28 -0800 Subject: [PATCH] Remove existing .npmrc when releasing to npmjs --- .../pipelines/templates/jobs/npm-publish.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/eng/common/pipelines/templates/jobs/npm-publish.yml b/eng/common/pipelines/templates/jobs/npm-publish.yml index ce51a7b58..74d733744 100644 --- a/eng/common/pipelines/templates/jobs/npm-publish.yml +++ b/eng/common/pipelines/templates/jobs/npm-publish.yml @@ -69,6 +69,22 @@ jobs: displayName: 'Packages to be published' - ${{ if eq(parameters.Registry, 'https://registry.npmjs.org/') }}: + + - task: PowerShell@2 + displayName: 'Delete repo .npmrc' + condition: and(succeeded(), ne(variables['SkipPublishing'], 'true')) + inputs: + targetType: inline + script: | + $npmrcPath = "$(System.DefaultWorkingDirectory)/.npmrc" + if (Test-Path $npmrcPath) { + Remove-Item -Path $npmrcPath -Force + Write-Host "Deleted $npmrcPath to use default npmjs registry." + } else { + Write-Host "No repo .npmrc found at $npmrcPath." + } + pwsh: true + - task: EsrpRelease@9 displayName: 'Publish ${{ parameters.ArtifactName }} via ESRP' condition: and(succeeded(), ne(variables['SkipPublishing'], 'true'))