Skip to content

Configuration

You can modify BaGet's configurations by editing the appsettings.json file.

Require an API key

You can require that users provide a password, called an API key, to publish packages. To do so, you can insert the desired API key in the ApiKey field.

{
    "ApiKey": "NUGET-SERVER-API-KEY",
    ...
}

Users will now have to provide the API key to push packages:

dotnet nuget push -s http://localhost:5000/v3/index.json -k NUGET-SERVER-API-KEY package.1.0.0.nupkg

Enable read-through caching

Read-through caching lets you index packages from an upstream source. You can use read-through caching to:

  1. Speed up your builds if restores from nuget.org are slow
  2. Enable package restores in offline scenarios

The following Mirror setting configures BaGet to index packages from nuget.org:

{
    ...

    "Mirror": {
        "Enabled":  true,
        "PackageSource": "https://api.nuget.org/v3/index.json"
    },

    ...
}

Info

PackageSource is the value of the NuGet service index.

Enable package hard deletions

To prevent the "left pad" problem, BaGet's default configuration doesn't allow package deletions. Whenever BaGet receives a package deletion request, it will instead "unlist" the package. An unlisted package is undiscoverable but can still be downloaded if you know the package's id and version. You can override this behavior by setting the PackageDeletionBehavior:

{
    ...

    "PackageDeletionBehavior": "HardDelete",

    ...
}

Enable package overwrites

Normally, BaGet will reject a package upload if the id and version are already taken. You can configure BaGet to overwrite the already existing package by setting AllowPackageOverwrites:

{
    ...

    "AllowPackageOverwrites": true,

    ...
}

Private feeds

A private feed requires users to authenticate before accessing packages.

Warning

Private feeds are not supported at this time! See this pull request for more information.

Database configuration

BaGet supports multiple database engines for storing package information:

  • MySQL: MySql
  • SQLite: Sqlite
  • SQL Server: SqlServer
  • PostgreSQL: PostgreSql
  • Azure Table Storage: AzureTable

Each database engine requires a connection string to configure the connection. Please refer to ConnectionStrings.com to learn how to create the proper connection string for each database engine.

You may configure the chosen database engine either using environment variables or by editing the appsettings.json file.

Environment Variables

There are two environment variables related to database configuration. These are:

  • Database__Type: The database engine to use, this should be one of the strings from the above list such as PostgreSql or Sqlite.
  • Database__ConnectionString: The connection string for your database engine.

appsettings.json

The database settings are located under the Database key in the appsettings.json configuration file:

{
    ...

    "Database": {
        "Type": "Sqlite",
        "ConnectionString": "Data Source=baget.db"
    },

    ...
}

There are two settings related to the database configuration:

  • Type: The database engine to use, this should be one of the strings from the above list such as PostgreSql or Sqlite.
  • ConnectionString: The connection string for your database engine.

IIS server options

IIS Server options can be configured under the IISServerOptions key. The available options are detailed at docs.microsoft.com Note: If not specified, the MaxRequestBodySize in BaGet defaults to 250MB (262144000 bytes), rather than the ASP.NET Core default of 30MB

{
    ...

    "IISServerOptions": {
        "MaxRequestBodySize": 262144000
    },

    ...
}