Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Publishing .NET Packages to NuGet.org with an API Key

说明与用途

使用 GitHub Actions 安全地将 .NET 包发布到 NuGet.org 的自动化流程。

问题

Automating the publishing of .NET libraries to NuGet.org while keeping API keys secure.

结果

Automated, secure publishing of .NET packages with minimal manual intervention and reduced risk of credential leakage.

工作流

  • Create a NuGet API key with Push scope and optional package pattern
  • Store the API key as a GitHub Actions repository secret (e.g., NUGET_API_KEY)
  • Add a workflow step that runs dotnet nuget push with --api-key "$NUGET_API_KEY" and --source https://api.nuget.org/v3/index.json
  • Optionally include --skip-duplicate to avoid failures on reruns

证据

never commit the API key into the repository

来源

The basic command is: dotnet nuget push <PACKAGE_FILE> --api-key <YOUR_API_KEY> --source https://api.nuget.org/v3/index.json

来源

  • 记录日期: 2026-09-15T18:30:21.148Z