This job takes the artifacts build in the `dotnet-package` step and publishes them depending upon the output type configured in the project files:
- Application binaries are zipped and always pushed to the generic GitLab Package Registry.
- Nuget packages get pushed to the configured NuGet target repo using [`dotnet nuget push`](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-push). Default repo is the Gitlab Nuget Repo of the project.
See also [.NET Build Configuration Best Practices](#net-build-configuration-best-practices) to control the per project behavior of the pipeline template.
**Note on Authentication:** The job is designed to work seamlessly with the integrated GitLab Package Registry. By default, `DOTNET_NUGET_API_KEY` uses the `CI_JOB_TOKEN`, so you do not need to configure any secret variables. You only need to create and set `DOTNET_NUGET_API_KEY` as a project CI/CD variable if you override `nuget-repo` to publish to an external repository (like nuget.org or another private registry) that requires a specific API key.
**Execution rules:**
- Runs automatically on **tagged release pipelines** with non-prerelease versions.
- Runs manually on any other pipeline instance.
- Automatically configured for GitLab Package Registry using `CI_JOB_TOKEN`
- Publishes both `.nupkg` and `.snupkg` (symbol) packages if symbol package publication is activated.
- Publishes executable binaries for configured _frameworks_ and the runner _runtime_.
**Important notes:**
- Automatically configures GitLab Package Registry as the NuGet target feed.
- Uses `CI_JOB_TOKEN` for authentication (no manual configuration needed to use with the GitLab package repository)
- See [Project / Solution Versioning](#solution--project-versioning) for the build version selection.
| `publish-enabled` / `DOTNET_PUBLISH_ENABLED` | Set to true to enable publishing of artifact to a [NuGet feed](https://www.nuget.org/). | `false` |
| `nuget-repo` / `DOTNET_NUGET_REPO` | Target NuGet package repository url to publish the packages to. (when overriding this, please set `DOTNET_NUGET_API_KEY` at project CI variable to set the [nuget api-key used by dotnet nuget push](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-push)) _defaults to [GitLab project's packages repository](https://docs.gitlab.com/user/packages/nuget_repository/)_ | `${CI_SERVER_URL}/api/v4/projects/${CI_PROJECT_ID}/packages/nuget/index.json` |
| :lock: `DOTNET_NUGET_API_KEY` | NuGet Repo API token used for authentication. | ${CI_JOB_TOKEN} |
| `nuget-symbol-repo` / `DOTNET_NUGET_SYMBOL_REPO` | Target NuGet package symbol repository url to publish the symbol packages to. (when overriding this, please set `DOTNET_NUGET_SYMBOL_API_KEY` at project CI variable to set the [nuget symbol api-key used by dotnet nuget push](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-push)) _defaults to [GitLab project's packages repository](https://docs.gitlab.com/user/packages/nuget_repository/)_ | `${CI_SERVER_URL}/api/v4/projects/${CI_PROJECT_ID}/packages/nuget/index.json` |
| :lock: `DOTNET_NUGET_SYMBOL_API_KEY` | NuGet Symbol Repo API token used for authentication. | ${CI_JOB_TOKEN} |
### Secrets management
Here are some advices about your **secrets** (variables marked with a :lock:):
"description":"Publishes built packages (with [dotnet publish](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish)) to a [NuGet feed](https://www.nuget.org/).",
"enable_with":"DOTNET_PUBLISH_ENABLED",
"variables":[
{
"name":"DOTNET_NUGET_REPO",
"description":"Target NuGet package repository url to publish the packages to. (when overriding this, please set `DOTNET_NUGET_API_KEY` at project CI variable to set the [nuget api-key used by dotnet nuget push](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-push)) _defaults to [GitLab project's packages repository](https://docs.gitlab.com/user/packages/nuget_repository/)_",
"description":"NuGet Repo API token used for authentication.",
"secret":true
},
{
"name":"DOTNET_PACKAGE_CONFIGURATION",
"description":"The build configuration to use for packaging (Debug or Release) a [library](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-pack) or [executable](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish)",
"default":"Release",
"advanced":true
},
{
"name":"DOTNET_PACKAGE_SYMBOLS_DISABLED",
"description":"Disable creation of symbol packages (snupkg) for debugging",
"default":"false",
"advanced":true
},
{
"name":"DOTNET_NUGET_SYMBOL_REPO",
"description":"Target NuGet package symbol repository url to publish the symbol packages to. (when overriding this, please set `DOTNET_NUGET_SYMBOL_API_KEY` at project CI variable to set the [nuget symbol api-key used by dotnet nuget push](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-push)) _defaults to [GitLab project's packages repository](https://docs.gitlab.com/user/packages/nuget_repository/)_",