info:To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers
---
# GitLab NuGet Repository
# NuGet packages in the Package Registry
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/20050) in [GitLab Premium](https://about.gitlab.com/pricing/) 12.8.
> - [Moved](https://gitlab.com/gitlab-org/gitlab/-/issues/221259) to GitLab Core in 13.3.
With the GitLab NuGet Repository, every project can have its own space to store NuGet packages.
Publish NuGet packages in your project’s Package Registry. Then, install the
packages whenever you need to use them as a dependency.
[NuGet CLI 5.1 or later](https://www.nuget.org/downloads) is required. Earlier versions have not been tested
against the GitLab NuGet Repository and might not work. If you have [Visual Studio](https://visualstudio.microsoft.com/vs/),
NuGet CLI is probably already installed.
The required minimum versions are:
Alternatively, you can use [.NET SDK 3.0 or later](https://dotnet.microsoft.com/download/dotnet-core/3.0), which installs NuGet CLI.
-[NuGet CLI 5.1 or later](https://www.nuget.org/downloads). If you have
[Visual Studio](https://visualstudio.microsoft.com/vs/), the NuGet CLI is
probably already installed.
- Alternatively, you can use [.NET SDK 3.0 or later](https://dotnet.microsoft.com/download/dotnet-core/3.0),
which installs the NuGet CLI.
- NuGet protocol version 3 or later.
You can confirm that [NuGet CLI](https://www.nuget.org/) is properly installed with:
Verify that the [NuGet CLI](https://www.nuget.org/) is installed by running:
```shell
nuget help
```
You should see something similar to:
The output should be similar to:
```plaintext
NuGet Version: 5.1.0.6013
...
...
@@ -43,103 +47,98 @@ Available commands:
[output truncated]
```
NOTE: **Note:**
GitLab currently only supports NuGet's protocol version 3. Earlier versions are not supported.
### Install NuGet on macOS
### macOS support
For macOS, you can use [Mono](https://www.mono-project.com/) to run the
NuGet CLI.
For macOS, you can also use [Mono](https://www.mono-project.com/) to run
the NuGet CLI. For Homebrew users, run `brew install mono` to install
Mono. Then you should be able to download the Windows C# binary
`nuget.exe` from the [NuGet CLI page](https://www.nuget.org/downloads)
and run:
1. If you use Homebrew, to install Mono, run `brew install mono`.
1. Download the Windows C# binary `nuget.exe` from the [NuGet CLI page](https://www.nuget.org/downloads).
1. Run this command:
```shell
mono nuget.exe
```
## Enabling the NuGet Repository
NOTE: **Note:**
This option is available only if your GitLab administrator has
[enabled support for the Package Registry](../../../administration/packages/index.md).
When the NuGet Repository is enabled, it is available for all new projects
by default. To enable it for existing projects, or if you want to disable it:
1. Navigate to your project's **Settings > General > Visibility, project features, permissions**.
1. Find the Packages feature and enable or disable it.
1. Click on **Save changes** for the changes to take effect.
```shell
mono nuget.exe
```
You should then be able to see the **Packages & Registries** section on the left sidebar.
## Add the Package Registry as a source for NuGet packages
## Adding the GitLab NuGet Repository as a source to NuGet
To publish and install packages to the Package Registry, you must add the
Package Registry as a source for your packages.
You need the following:
Prerequisites:
- Your GitLab username.
- A personal access token or deploy token. For repository authentication:
- You can generate a [personal access token](../../../user/profile/personal_access_tokens.md) with the scope set to `api`.
- You can generate a [deploy token](./../../project/deploy_tokens/index.md) with the scope set to `read_package_registry`, `write_package_registry`, or both.
- A suitable name for your source.
- Your project ID which can be found on the home page of your project.
- You can generate a [personal access token](../../../user/profile/personal_access_tokens.md)
with the scope set to `api`.
- You can generate a [deploy token](./../../project/deploy_tokens/index.md)
with the scope set to `read_package_registry`, `write_package_registry`, or
both.
- A name for your source.
- Your project ID, which is found on your project's home page.
@@ -147,46 +146,51 @@ To add the GitLab NuGet Repository as a source for .NET, create a file named `nu
<addkey="ClearTextPassword"value="<gitlab_personal_access_token or deploy_token>"/>
</gitlab>
</packageSourceCredentials>
</configuration>
```
</configuration>
```
## Publish a NuGet package
When publishing packages:
## Uploading packages
- The Package Registry on GitLab.com can store up to 500 MB of content.
This limit is [configurable for self-managed GitLab instances](../../../administration/instance_limits.md#package-registry-limits).
- If you publish the same package with the same version multiple times, each
consecutive upload is saved as a separate file. When installing a package,
GitLab serves the most recent file.
- When publishing packages to GitLab, they aren't displayed in the packages user
interface of your project immediately. It can take up to 10 minutes to process
a package.
When uploading packages, note that:
### Publish a package with the NuGet CLI
- The Package Registry on GitLab.com can store up to 500 MB of content. This limit is [configurable for self-managed GitLab instances](../../../administration/instance_limits.md#package-registry-limits).
- If you upload the same package with the same version multiple times, each consecutive upload
is saved as a separate file. When installing a package, GitLab serves the most recent file.
- When uploading packages to GitLab, they are not displayed in the packages UI of your project
immediately. It can take up to 10 minutes to process a package.
Prerequisite:
### Upload packages with NuGet CLI
-[A NuGet package created with NuGet CLI](https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package).
This section assumes that your project is properly built and you already [created a NuGet package with NuGet CLI](https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package).
Upload your package using the following command:
Publish a package by running this command:
```shell
nuget push <package_file> -Source <source_name>
```
Where:
-`<package_file>` is your package filename, ending in `.nupkg`.
-`<source_name>` is the [source name used during setup](#adding-the-gitlab-nuget-repository-as-a-source-to-nuget).
-`<source_name>` is the [source name used during setup](#add-a-source-with-the-nuget-cli).
### Publish a package with the .NET CLI
### Upload packages with .NET CLI
Prerequisite:
This section assumes that your project is properly built and you already [created a NuGet package with .NET CLI](https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package-dotnet-cli).
Upload your package using the following command:
[A NuGet package created with .NET CLI](https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package-dotnet-cli).