Docs/Getting Started/Quick Start: NuGet

Quick Start: NuGet

Get your first NuGet package published and consumed through DepAegis in under five minutes. This guide walks you through creating a class library, packing it, pushing it to your private registry, and installing it in another project.

Prerequisites

Not using NuGet? See the Quick Start: npm or Quick Start: Docker guides instead.

Step 1 — Create an access token

DepAegis authenticates NuGet operations using Personal Access Tokens (PATs). Create one from the DepAegis dashboard:

  1. Navigate to Settings → Access Tokens
  2. Click Generate new token
  3. Give it a descriptive name (e.g. nuget-cli)
  4. Select the write:packages scope if you plan to publish
  5. Copy the token value — you will not be able to see it again
Store your access token securely. Treat it like a password — never commit it to source control. For CI/CD, use a secrets manager or your pipeline's built-in secret store.

Step 2 — Configure the NuGet source

Register DepAegis as a NuGet package source. The NuGet endpoint is https://app.depaegis.com/api/v1/nuget/v3/index.json.

Option A: .NET CLI

dotnet nuget add source "https://app.depaegis.com/api/v1/nuget/v3/index.json" \
  --name depaegis \
  --username "<your-username>" \
  --password "<your-access-token>" \
  --store-password-in-clear-text
The --store-password-in-clear-text flag is required because the .NET SDK cannot prompt for credentials during dotnet push or dotnet restorein non-interactive environments.

Option B: nuget.config file

Alternatively, place a nuget.config file in your project or repository root:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="depaegis"
         value="https://app.depaegis.com/api/v1/nuget/v3/index.json" />
  </packageSources>
  <packageSourceCredentials>
    <depaegis>
      <add key="Username" value="<your-username>" />
      <add key="ClearTextPassword" value="<your-access-token>" />
    </depaegis>
  </packageSourceCredentials>
</configuration>
If you use the nuget.config approach, add it to your .gitignore to avoid leaking credentials. For team setups, consider using environment variable substitution or a CI secret store.

Step 3 — Create a class library

Create a new class library project that will become your NuGet package:

mkdir MyCompany.Utils && cd MyCompany.Utils
dotnet new classlib -n MyCompany.Utils

Add some code to the default class file. For example, open Class1.cs and replace its contents:

namespace MyCompany.Utils;

public static class StringExtensions
{
    public static bool IsNullOrEmpty(this string? value)
        => string.IsNullOrEmpty(value);
}

Step 4 — Pack the package

Build and pack the library into a .nupkg file:

dotnet pack -c Release

The resulting package will be in bin/Release/MyCompany.Utils.1.0.0.nupkg. You can customize the version, description, and other metadata in the .csproj file:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <PackageId>MyCompany.Utils</PackageId>
    <Version>1.0.0</Version>
    <Authors>Your Name</Authors>
    <Description>Shared utility extensions for MyCompany projects.</Description>
    <PackageLicenseExpression>MIT</PackageLicenseExpression>
  </PropertyGroup>
</Project>

Step 5 — Push to DepAegis

Publish the package to your DepAegis registry:

dotnet nuget push "bin/Release/MyCompany.Utils.1.0.0.nupkg" \
  --source depaegis

If you did not name your source depaegis, use the full URL instead:

dotnet nuget push "bin/Release/MyCompany.Utils.1.0.0.nupkg" \
  --source "https://app.depaegis.com/api/v1/nuget/v3/index.json" \
  --api-key "<your-access-token>"
DepAegis will automatically scan the package for vulnerabilities and generate an SBOM upon upload. Check the package page in the dashboard to view the results.

Step 6 — Consume the package

In another project, install the package from DepAegis:

dotnet add package MyCompany.Utils --source depaegis

Or add it directly to your .csproj file:

<ItemGroup>
  <PackageReference Include="MyCompany.Utils" Version="1.0.0" />
</ItemGroup>

Then restore and use it:

dotnet restore --source depaegis
using MyCompany.Utils;

var input = Console.ReadLine();
if (input.IsNullOrEmpty())
{
    Console.WriteLine("No input provided.");
}

Step 7 — Verify the security scan

Open the DepAegis dashboard and navigate to the package page for MyCompany.Utils. You will see:

If your organization has configured a Dependency Firewall, packages that fail policy checks will be quarantined. You can review and override quarantined packages from the dashboard.

Next steps