Josepe
Josepe

Reputation: 21

Publishing NuGet package to Github

I have a Github repository for a C# Class Library project:
https://github.com/JosepeDev/VarEnc

I've created a NuGet package file through Visual Studio and uploaded it to Nuget:
https://www.nuget.org/packages/VarEnc/

How can I link this NuGet package to my GitHub packages?
Should I use Actions?

Upvotes: 2

Views: 520

Answers (1)

DarkSideMoon
DarkSideMoon

Reputation: 1063

One of the best way to reach this goal - introduce CI/CD into your project/repository. In your situation it is better to choose cloud solution.

Tools

There are a lot of cool instruments for this purpose:

I can describe few tools that I am use.

Github Actions

  1. In marketplace of Github Actions you can find template and example of configuration
  2. Also there is soluiton for this How to push nuget package in GitHub actions
  3. And there is helpful article

AppVeyor

To configure this CI, do the following steps:

  1. Create account on AppVeyor, login and add your project to CI
  2. Create appveyor.yml file in your root repository
  3. In yml script you need to configure - image, build_script, version. Example:
image: Visual Studio 2019

build_script:
  - ps: dotnet --info
  - ps: dotnet restore VarEnc.sln
  - ps: dotnet build VarEnc.sln

version: 0.0.1.{build}
  1. Add deploy section in your appveyor.yml file
deploy:
- provider: NuGet
  server: path to nuget org your package
  api_key:
    secure: ...
  skip_symbols: true
  on:
    branch: master
- provider: NuGet
  name: production
  api_key:
    secure: ...
  on:
    branch: master
    appveyor_repo_tag: true

For more information about AppVeyor publish you can find in official documentation or helpful article from Andrew Lock

Travis CI

The same situation for Travis CI tool, but yml file will be a little bit different.

  1. The same step from AppVeyor approach
  2. Create .travis.yml file in your root repository
  3. Configure initial yml script
language: csharp
dist: xenial
sudo: required
solution: VarEnc.sln
mono: none
dotnet: 3.1

script:
 - dotnet --version
 - dotnet restore
 - dotnet build
  1. Configure deploy in script. Solution you can find here - How do I deploy nuget packages in Travis CI?

Enjoy of configuring your CI in project! github

Upvotes: 4

Related Questions