Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions eng/pipelines/templates/BuildAndTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,20 @@ steps:
displayName: Pack docs transport package

- pwsh: |
Write-Host "--- npm config diagnostics ---"
npm config list
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm config list can print a large portion of npm’s effective configuration, which may include registry credentials from agent/user/global configs. Since this runs in CI logs, consider limiting diagnostics to only the specific config paths and a small set of non-sensitive keys (e.g., which config files are being used and what registry is selected), or otherwise ensuring any auth values are redacted before output.

Suggested change
npm config list
Write-Host ("npm userconfig: " + (npm config get userconfig))
Write-Host ("npm globalconfig:" + (npm config get globalconfig))
Write-Host ("npm registry: " + (npm config get registry))

Copilot uses AI. Check for mistakes.
Write-Host "--- end diagnostics ---"
$(Build.SourcesDirectory)/src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/azure-devops-report/build.ps1 -OutputPath $(Build.Arcade.VSIXOutputPath)
displayName: Build Azure DevOps plugin
env:
# Some CI agents have stale npm auth tokens in the user-level .npmrc
# (e.g. C:\Users\cloudtest\.npmrc). npm sends these stale credentials
# to the public dotnet-public-npm feed, causing E401 errors. Override
# the user config path to a non-existent file so npm ignores stale
# credentials and uses anonymous access for the public feed.
# Some CI agents have stale npm auth tokens in user or global .npmrc
# files (e.g. C:\Users\cloudtest\.npmrc). npm sends these stale
# credentials to the public dotnet-public-npm feed, causing E401.
# Override both user and global config paths to non-existent files
# so npm only reads the project-level .npmrc (which has the registry
# URL but no auth tokens).
Comment on lines +181 to +182
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says overriding user/global config means npm will only read the project-level .npmrc (URL/no auth). In this script, npm runs in multiple directories, and not all of them appear to have a project .npmrc (e.g., the repo-level install). Consider adjusting the wording to reflect that this forces npm to ignore user/global configs and rely on project config when present (otherwise built-in defaults), to avoid confusion for future maintenance.

Suggested change
# so npm only reads the project-level .npmrc (which has the registry
# URL but no auth tokens).
# so npm ignores user/global .npmrc files and instead uses any
# project-level .npmrc present (with the registry URL but no auth
# tokens), or npm's built-in defaults if none exist.

Copilot uses AI. Check for mistakes.
NPM_CONFIG_USERCONFIG: $(Agent.TempDirectory)/.npmrc-not-exists
NPM_CONFIG_GLOBALCONFIG: $(Agent.TempDirectory)/.npmrc-not-exists

- script: ${{ parameters.buildScript }}
-restore
Expand Down
Loading