Aller au contenu
Skillpedia
Déploiement et cloud (DevOps)5.8k · #14556

nuget-trusted-publishing

Ce qu’il fait

Cette skill configure la publication automatique de paquets NuGet depuis GitHub Actions avec OpenID Connect, sans clé API de longue durée. Elle s'adresse aux mainteneurs de paquets .NET publiés sur nuget.org.

Quand l’utiliser

  • ✓Quand vous voulez publier un paquet NuGet depuis GitHub Actions sans clé API stockée.
  • ✓Quand vous faites passer un flux de publication NuGet existant d'une clé API à la publication de confiance.
  • ✓Quand vous créez un flux de publication NuGet à partir de zéro.

Lien du skill

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

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/dotnet/skills/blob/main/plugins/dotnet-advanced/skills/nuget-trusted-publishing/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Configure la publication de confiance pour mon paquet NuGet afin que le workflow GitHub Actions n'ait plus besoin de clé API.”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

L'agent vérifie le dépôt et le paquet, vous guide dans la configuration de la publication de confiance sur nuget.org, met à jour le workflow pour utiliser des jetons de courte durée, et demande votre accord avant de supprimer un ancien secret.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis 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

Questions fréquentes

Fonctionne-t-elle pour les flux privés ?

Non. Elle concerne uniquement nuget.org, et non les flux privés ni Azure Artifacts.

Supprime-t-elle mon ancienne clé API ?

Pas sans vous demander d'abord, car la suppression de secrets et le changement d'identifiants de paquets nécessitent une confirmation.

Faut-il GitHub Actions ?

Oui. Elle ne couvre que les configurations GitHub Actions.

Détails

Description originale de l’auteur

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

Popularité

Étoiles GitHub
5.8k
Position au classement
#14556
Licence
MIT
Mis à jour
02/11/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires