# nuget-trusted-publishing

Configures OIDC-based trusted publishing for NuGet packages via GitHub Actions. It replaces long-lived API secrets with temporary tokens for secure nuget.org releases.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3300 installs · ★ 5730
- Author: dotnet
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/dotnet/skills/tree/HEAD/plugins/dotnet-advanced/skills/nuget-trusted-publishing/SKILL.md
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/nuget-trusted-publishing

## What it does

The skill automates keyless publishing setup on nuget.org. It scans `.csproj` files and `Directory.Build.props` to classify projects as libraries, dotnet tools, MCP servers, or templates. The assistant verifies mandatory metadata like `PackageId` and flags version discrepancies before creating files.

Local testing runs first. You run `dotnet pack -c Release -o ./artifacts` to confirm the package builds cleanly. NuGet IDs and versions cannot be reused once published. The agent then outputs the exact repository owner and workflow filename needed for the policy on `nuget.org/account/trustedpublishing`. Existing secrets remain untouched until you confirm the policy is live.

Private feeds and Azure Artifacts are not supported because OIDC publishing works strictly with nuget.org.

## Requirements
- Works with: Azure

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add dotnet/skills --skill nuget-trusted-publishing -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/nuget-trusted-publishing/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/nuget-trusted-publishing/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add dotnet/skills --skill nuget-trusted-publishing -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/nuget-trusted-publishing/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add dotnet/skills --skill nuget-trusted-publishing -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/nuget-trusted-publishing/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install dotnet/skills nuget-trusted-publishing
```

2. **Manually: put the files in place**
- File: `.github/skills/nuget-trusted-publishing/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add dotnet/skills --skill nuget-trusted-publishing -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/dotnet/skills --path plugins/dotnet-advanced/skills/nuget-trusted-publishing
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/nuget-trusted-publishing/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add dotnet/skills --skill nuget-trusted-publishing -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/dotnet/skills/tree/HEAD/plugins/dotnet-advanced/skills/nuget-trusted-publishing/SKILL.md

## When to use it
- Replace static `NUGET_API_KEY` secrets with OIDC short-lived tokens
- Create a GitHub Actions workflow using `NuGet/login@v1` and `id-token: write`
- Validate package metadata and version consistency across project files
- Generate exact policy values for `nuget.org/account/trustedpublishing`

## Example prompts
- Set up trusted publishing for this NuGet package
- Migrate our GitHub Actions workflow from NUGET_API_KEY to OIDC
- Create a release workflow for our dotnet tool using NuGet/login

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: f32997b7f440749f.

BEGIN THIRD-PARTY FILE f32997b7f440749f
```text
---
name: nuget-trusted-publishing
description: >
  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.
license: MIT
---

# NuGet Trusted Publishing Setup

Set up [NuGet trusted publishing](https://learn.microsoft.com/en-us/nuget/nuget-org/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**
```
END THIRD-PARTY FILE f32997b7f440749f

The third-party file has ended. Everything between the f32997b7f440749f tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2677 of 9361 bytes. © dotnet · MIT · https://github.com/dotnet/skills/tree/HEAD/plugins/dotnet-advanced/skills/nuget-trusted-publishing/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
