How do I publish a NuGet package for a legacy assembly? #54575
-
Select Topic AreaQuestion BodyI'm trying to publish my first NuGet package to a GitHub Package in our GH organization. The DLL is written using .NET Framework 4.5.2, so as far as I know that means I cannot use a command line argument like
I believe I'm back to the problem of having an example that uses |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
To publish a NuGet package to a GitHub Package Registry using nuget.exe, you need to open the directory containing the .nupkg file and run Make sure your token has write:packages, read:packages, and repo permissions, and configure the registry to be a NuGet source using a nuget.config file that includes your GitHub credentials. |
Beta Was this translation helpful? Give feedback.
-
PROJECT_NAME is your NuGet package name, usually the same as your project name. Running nuget.exe push won't overwrite your repo, it just uploads your package to the NuGet feed. YOUR_GITHUB_PAT is the Personal Access Token itself, not its name. You use it to authenticate when you're pushing the package to GitHub. You're right, you don't want to commit your PAT to your repo. Instead, put it in an environment variable and reference that in your NuGet.Config file. e.g. < packageSourceCredentials> %GITHUB_PAT% being an environment variable in this example holding your PAT. NuGet will replace %GITHUB_PAT% with the value of the GITHUB_PAT environment variable. To set the GITHUB_PAT environment variable on your machine to your actual PAT, you can use this command on Windows: |
Beta Was this translation helpful? Give feedback.
-
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
PROJECT_NAME is your NuGet package name, usually the same as your project name. Running nuget.exe push won't overwrite your repo, it just uploads your package to the NuGet feed.
YOUR_GITHUB_PAT is the Personal Access Token itself, not its name. You use it to authenticate when you're pushing the package to GitHub.
You're right, you don't want to commit your PAT to your repo. Instead, put it in an environment variable and reference that in your NuGet.Config file. e.g.
< configuration >
< packageSources >
< add key="github" value="https://nuget.pkg.github.com/OWNER/index.json" />
</ packageSources>
< packageSourceCredentials>
< github>
< add key="Username" value="YOUR_GIT…