Skip to content
Skillpedia
Deploy & cloud (DevOps)5.8k Β· #14556

nuget-trusted-publishing

What it does

This skill sets up automatic NuGet publishing from GitHub Actions using OpenID Connect, removing the need for long-lived API keys. It is for maintainers of .NET packages published to nuget.org.

When to use it

  • βœ“When you want to publish a NuGet package from GitHub Actions without a stored API key.
  • βœ“When you are moving an existing NuGet publish workflow off an API key.
  • βœ“When you are creating a new NuGet publish workflow from scratch.

Skill link

https://github.com/dotnet/skills/blob/main/plugins/dotnet-advanced/skills/nuget-trusted-publishing/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/dotnet/skills/blob/main/plugins/dotnet-advanced/skills/nuget-trusted-publishing/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œSet up trusted publishing for my NuGet package so the GitHub Actions workflow no longer needs an API key.”

5 new skills a week. 1 minute to read.

How it works

The agent checks the repo and package, guides the nuget.org trusted publishing setup, updates the workflow to use short-lived tokens, and asks before removing any old secret.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

NuGet Trusted Publishing Setup

Set up NuGet trusted publishing on a GitHub Actions repo. Replaces long-lived API keys with OIDC-based short-lived tokens β€” no secrets to rotate or leak.

Prerequisites

  • GitHub Actions β€” this skill covers GitHub Actions setup only
  • nuget.org account β€” the user needs access to create trusted publishing policies

When to Use This Skill

Use this skill when:

  • Setting up trusted publishing for a NuGet package
  • Migrating from secrets.NUGET_API_KEY to OIDC-based publishing
  • Asked about keyless or secure NuGet publishing
  • Creating a new NuGet publish workflow from scratch
  • Asked to "remove NuGet API key" or "use NuGet/login"
  • Setting up publishing for a dotnet tool, MCP server, or template package
  • Asked about NuGet/login@v1 or id-token: write

Safety Rules

⚠️ Bail-out rule: If any phase fails after one fix attempt on an infrastructure/auth issue, stop and ask the user. Don't loop on environment problems.

⚠️ Never delete or overwrite without confirmation: Removing API key secrets, deleting tags/releases, removing workflow steps, or changing package IDs. NuGet package IDs are permanent β€” mistakes can't be undone.

Process

Fast-path for greenfield repos: When the user has a simple setup (one packable project, no existing publish workflow), don't gate on multi-turn assessment. Combine phases: create the workflow immediately, include nuget.org policy guidance, local pack recommendation, and filename-matching warning all in one response. The full phased process below is for complex or migration scenarios.

Phase 1: Assess

Inspect the repo and report findings before making any changes.

  1. Find and classify packable projects β€” check .csproj files and Directory.Build.props (package metadata is often set repo-wide). Classify in this order (earlier matches win):

    • <PackageType>Template</PackageType> β†’ Template
    • <PackageType>McpServer</PackageType> β†’ MCP server (also a dotnet tool)
    • <PackAsTool>true</PackAsTool> β†’ Dotnet tool
    • Class library (IsPackable=true or no OutputType) β†’ Library
    • <OutputType>Exe</OutputType> with <IsPackable>true</IsPackable> β†’ Application package (not a tool, but still publishable)
    • <OutputType>Exe</OutputType> without PackAsTool or IsPackable β†’ Not packable by default (ask user if they intend to publish it)
  2. Validate structure for each project's type:

    Type Required
    All PackageId, Version (in .csproj or Directory.Build.props)
    Dotnet tool PackAsTool (required); ToolCommandName (optional but recommended β€” defaults to assembly name)
    MCP server PackageType=McpServer, .mcp/server.json included in package
    Template PackageType=Template, .template.config/template.json under content dir
  3. Find existing publish workflows in .github/workflows/ β€” look for dotnet nuget push, nuget push, or dotnet pack.

  4. Check version consistency β€” for MCP servers, verify .csproj <Version> matches both server.json version fields (root version and packages[].version). Flag any mismatch.

  5. Report findings to the user: classification, missing properties, version mismatches, existing workflows. For multi-project repos, note whether one workflow or separate workflows per package are needed. Offer to fix gaps β€” use ask_user before modifying project files.

❌ See references/package-types.md for per-type details and required properties.

Phase 2: Local Verification

Pack and verify locally before touching nuget.org β€” publishing errors waste a permanent version number.

⚠️ Always mention this step, even if you defer running it. Tell the user: "Before your first publish, run dotnet pack -c Release -o ./artifacts to verify the .nupkg is created correctly."

  1. dotnet pack -c Release -o ./artifacts β€” verify .nupkg is created
  2. For tools/MCP servers: install from ./artifacts, run --help, uninstall
  3. For libraries: inspect the .nupkg contents (it's a zip)

Phase 3: nuget.org Policy

This phase requires the user to act on nuget.org β€” guide them with exact values.

  1. Determine the repo owner, repo name, and the workflow filename that will publish.

    ❌ The policy requires the exact workflow filename (e.g., `pu

FAQ

Does it work for private feeds?

No. It is for nuget.org only, not private feeds or Azure Artifacts.

Does it delete my old API key?

Not without asking you first, since removing secrets and changing package IDs needs confirmation.

Does it need GitHub Actions?

Yes. It covers GitHub Actions setups only.

Details

Original description by the author

Set up NuGet trusted publishing (OIDC) on a GitHub Actions repo β€” replaces long-lived API keys with short-lived tokens. USE FOR: trusted publishing, NuGet OIDC, keyless NuGet publish, migrate from NuGet API key, NuGet/login, secure NuGet publishing. DO NOT USE FOR: publishing to private feeds or Azure Artifacts (OIDC is nuget.org only). INVOKES: shell (powershell or bash), edit, create, ask_user for guided repo setup.

repo: dotnet/skills

Popularity

GitHub stars
5.8k
Ranking position
#14556
License
MIT
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills