To use this package you must add MTD's GitHub NuGet feed as a source. To do so,
add a NuGet.config
file to the root of your project
with the following content:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="github" value="https://nuget.pkg.github.com/CUMTD/index.json" />
</packageSources>
<packageSourceCredentials>
<github>
<add key="Username" value="%MtdGithubUserName%" />
<add key="ClearTextPassword" value="%MtdGithubAccessToken%" />
</github>
</packageSourceCredentials>
<packageSourceMapping>
<packageSource key="nuget.org">
<package pattern="*" />
</packageSource>
<packageSource key="github">
<package pattern="Mtd.*" />
</packageSource>
</packageSourceMapping>
<disabledPackageSources />
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>
After adding the nuget config file, you must add environment variables to authenticate with GitHub. To do so, you need a personal access Token. You will need a unique token for each local machine on which you do development.
- In GitHub, navigate to Settings > Developer Settings > Personal Access Tokens > Tokens (Classic). Select Generate New Token > Generate New Token (Classic).
- Create a token with the
read:packages
permission. - Take note of the generated token.
Note: Make sure you are going to your personal settings not the organization settings.
The final step to get going locally is to tell your environment about your personal access token.
From PowerShell, run the following commands:
setx MtdGithubUserName <YOUR_GITHUB_USERNAME>
setx MtdGithubAccessToken <YOUR_PERSONAL_ACCESS_TOKEN>
You can use the secrets.GITHUB_TOKEN
token to access this repository
in another project.
A sample YML is below:
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: .NET Build and Test
on:
workflow_dispatch:
push:
branches: ['main']
pull_request:
branches: ['main']
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: read
env:
MtdGithubUserName: CUMTD
MtdGithubAccessToken: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore Mtd.Test.sln
- name: Build
run: dotnet build --no-restore Mtd.Test.sln
- name: Test
run: dotnet test --no-build --verbosity normal