Docs/NuGet Registry/Installing NuGet Packages

Installing NuGet Packages

Learn how to install and restore packages from DepAegis into your .NET projects using the dotnet CLI, PackageReference, and Visual Studio.

Installing with dotnet add package

The easiest way to add a package from DepAegis is the dotnet add package command:

dotnet add package MyCompany.Utils

To install a specific version:

dotnet add package MyCompany.Utils --version 2.1.0

To install a pre-release version:

dotnet add package MyCompany.Utils --version 2.2.0-beta.1 --prerelease
dotnet add package will search all configured sources. Make sure DepAegis is configured as a source (see Configuring NuGet) and that you have a valid API key or credential.

PackageReference in .csproj

You can also add packages directly to your .csproj file using a PackageReference element:

<ItemGroup>
  <PackageReference Include="MyCompany.Utils" Version="2.1.0" />
  <PackageReference Include="MyCompany.Logging" Version="1.0.0-beta.2" />
</ItemGroup>

After editing the .csproj, run dotnet restore to download and resolve the packages.

Restoring Packages with dotnet restore

dotnet restoredownloads all packages listed in your project's dependencies:

dotnet restore

To restore from a specific source only:

dotnet restore --source "DepAegis"

This is useful for verifying that a private package is available on DepAegis without hitting nuget.org.

Version Ranges

NuGet supports version ranges in PackageReference to control which versions are acceptable during restore:

NotationMeaningResolved Version
1.0.0Exact version only1.0.0
[1.0.0, 2.0.0)>= 1.0.0, less than 2.0.0Highest 1.x
[1.0.0, )>= 1.0.0, no upper boundHighest available
(1.0.0, 2.0.0]Greater than 1.0.0, <= 2.0.0Highest up to 2.0.0
1.0.*Any 1.0.x patchHighest 1.0.x
For internal packages, prefer exact versions or narrow ranges like [1.0.0, 2.0.0) to avoid unexpected breaking changes. Use Dependency Firewall policies to enforce version constraints organization-wide.

Private Package Authentication in CI

When running in CI/CD pipelines, you need to provide DepAegis credentials without interactive prompts. The recommended approach is to configure the source and API key in your CI script:

# Add source with API key from CI secret
dotnet nuget add source "https://app.depaegis.com/api/v1/nuget/v3/index.json" \
  --name "DepAegis" \
  --username "ci-user" \
  --store-password-in-clear-text \
  --password "$DEPAEGIS_API_KEY"

# Restore packages
dotnet restore

Alternatively, you can use a nuget.config committed to the repository with the source URL (but not the API key), and inject credentials via environment variable:

# nuget.config (committed to repo)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="DepAegis" value="https://app.depaegis.com/api/v1/nuget/v3/index.json" />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
</configuration>
For detailed CI/CD setup guides, see GitHub Actions, GitLab CI, and Azure DevOps.

Troubleshooting Source Resolution

If packages are not being found on DepAegis, check these common issues:

1. Source not configured

Verify the source is registered:

dotnet nuget list source

If DepAegis is not listed, add it (see Configuring NuGet).

2. Authentication failure (401 / 403)

Ensure your API key is valid and has Read permissions:

dotnet nuget list source
# Check if credentials are stored for DepAegis source

Re-set the API key if needed:

dotnet nuget setapikey "your-new-api-key" --source "DepAegis"

3. Wrong feed URL

The NuGet v3 feed URL must end with /v3/index.json. Verify the URL in your nuget.config:

# Correct
https://app.depaegis.com/api/v1/nuget/v3/index.json

# Wrong (missing v3 endpoint)
https://app.depaegis.com/nuget

4. Package not found

If you see Unable to find package, check:

5. Locked or quarantined packages

If a package fails security scanning, it may be quarantined. Check the DepAegis dashboard for vulnerability reports. See Vulnerability Scanning for details on quarantine policies.