Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

An example project for a NuGet Package with code coverage, code quality and auto-deploy to nuget

License

Notifications You must be signed in to change notification settings

ajwgroup/NugetExampleProject

Repository files navigation

Nuget Example Project

An example project for a NuGet Package with code coverage, code quality and auto-deploy to nuget.

Travis-CI

The continuous integration platform used is Travis-CI.

There are several variables that need to be set to allow Travis to work correctly with automated builds.

Setting Environment Variables in Travis-CI

To set environment variables within travis CI follow this guide.

PROJECT_NAME

An essential variable that is required is the PROJECT_NAME variable. This is used to specify the project name for the project and allows for all references to the project name to be updated once from within the CI.

This variable should be set to the project name displayed at the end of the github url - https://github.com/ajwgroup/NugetExampleProject

NUGET_KEY

To be able to push the package to nuget in the deployment stage, the NUGET_KEY needs to be set.

The NUGET_KEY can be created by selecting 'API Keys' from the account menu drop down on the nuget website.

From here give the key a friendly name and set the key duration (This is 365 days by default).

If the package has already been published you can select an Available package, or you can specify a Glob pattern for the package(s) that you would like the API key to apply to. It's adviced to create a key for each package that is to be published so that keys can be revoked on a per package basis.

Once the token has been obtained add it to the CI variables as instructed above with the Key name NUGET_KEY.

Code Coverage

Codecov is used for displaying the projects test code coverage. Code coverage can be seen here.

No variables need to be set for the code coverage to published.

SonarCloud

SonarCloud is used to analyse the code and provide feedback on several aspects such as code quality, bugs, potential vulnerabilities among others.

Add new project

Add project details

Generate/Use Token

Open Project Settings in Travis

Add Sonar token to CI variables

The sonarcloud token should be set to the key SONARCLOUD_TOKEN.

Github Pages

To create and publish documentation for the nuget package DocFx is used within the project. DocFx uses a combination of markdown files and automatically generated content from comments within the code to produce a clean and easily navigable source of documentation and as such is recommended, though not necessary.

Setting up pages branch

Note: Ensure there is a branch 'gh-pages' available before allowing the CI to attempt to publish.

In the settings for the github project under the 'GitHub Pages' section, pick the 'gh-pages' branch as the source for the pages site.

Create Token

To provide travis with the ability to deploy the documentation you’ll need to generate a personal access token with the public_repo permission.

Since the token should be private, you’ll want to pass it to Travis securely in your repository settings. To generate a personal token follow this guide.

Deployment

Once the token has been generated and stored as GITHUB_TOKEN within travis, the CI for this example project should be able to publish any static files stored in {PROJECT_NAME}/_site, this is the default location used by DocFx to store the static files.

For more information on deploying to github pages read this guide to deploy to github pages.

Badges

For a consistent look it's recommended to use badges available from shields.io. Example Badges can be seen below.

  • License - MIT
  • Build Status
  • Issues
  • Latest Nuget Release Package not published
  • Latest Nuget Pre-Release Package not published
  • Coverage Status
  • Last commit
  • Code Quality

ToDo

  • Add in automated documentation generation
  • Generate a visual studio template project

About

An example project for a NuGet Package with code coverage, code quality and auto-deploy to nuget

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published