Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/create-packages/Symbol-Packages-snupkg.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ The [`SymbolPackageFormat`](/dotnet/core/tools/csproj#symbolpackageformat) prope
nuget SetApiKey Your-API-Key
```

> [!TIP]
> Starting with NuGet 7.6, you can set the `NUGET_API_KEY` and `NUGET_SYMBOL_API_KEY` environment variables instead of using `SetApiKey`.
> For more information, see [environment variables](../reference/cli-reference/cli-ref-environment-variables.md).

1. After publishing your primary package to nuget.org, push the symbol package as follows.

```cli
Expand Down
4 changes: 4 additions & 0 deletions docs/quickstart/includes/publish-dotnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ From the folder that contains the *.nupkg* file, run the following command. Repl
dotnet nuget push <package-file> --api-key <API-key> --source https://api.nuget.org/v3/index.json
```

> [!TIP]
> Starting with NuGet 7.6 (.NET SDK 10.0.300), you can set the `NUGET_API_KEY` environment variable instead of passing `--api-key` on the command line.
> This is useful in CI/CD scenarios where you don't want to pass the key as a command-line argument.

The output shows the results of the publishing process:

```output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@ The list of properties documented in [NuGet pack and restore as MSBuild targets]
| NUGET_XMLDOC_MODE | Determines how assemblies XML documentation file extraction should be handled. | Supported modes are *skip* (do not extract XML documentation files), *compress* (store XML doc files as a zip archive) or *none* (default, treat XML doc files as regular files). |
| NUGET_CERT_REVOCATION_MODE | Determines how the revocation status check of the certificate used to sign a package, is performed when a signed package is installed or restored. When not set, defaults to `online`.| Possible values *online* (default), *offline*. Related to [NU3028](../errors-and-warnings/NU3028.md) |
| NUGET_ENHANCED_MAX_NETWORK_TRY_COUNT | Configures the maximum number of times an HTTP connection should be retried when enhanced retries are enabled. | A number representing how many retries to perform, the default value is `6`. |
| NUGET_API_KEY | The API key used to authenticate when pushing packages. If not set, the value from the `apikeys` section of `NuGet.Config` is used. | Available in NuGet 7.6 and higher. The command-line option takes precedence over this environment variable. |
| NUGET_SYMBOL_API_KEY | The API key used to authenticate when pushing symbol packages. If not set, the value from the `apikeys` section of `NuGet.Config` is used. | Available in NuGet 7.6 and higher. The command-line option takes precedence over this environment variable. |
| NUGET_ENHANCED_NETWORK_RETRY_DELAY_MILLISECONDS | Configures the amount of time to wait in milliseconds before retrying an HTTP connection when enhanced retries are enabled. | Number of millseconds to wait, the default value is `1000`. |

4 changes: 2 additions & 2 deletions docs/reference/cli-reference/cli-ref-push.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ where `<packagePath>` identifies the package to push to the server.

- **`-ApiKey`**

The API key for the target repository. If not present, the one specified in the config file is used.
The API key for the target repository. If not present, the `NUGET_API_KEY` environment variable is read *(7.6+)*. If neither is set, the one specified in the config file is used.

- **`-ConfigFile`**

Expand Down Expand Up @@ -77,7 +77,7 @@ where `<packagePath>` identifies the package to push to the server.

- **`-SymbolApiKey`**

*(3.5+)* Specifies the API key for the URL specified in `-SymbolSource`.
*(3.5+)* Specifies the API key for the URL specified in `-SymbolSource`. If not present, the `NUGET_SYMBOL_API_KEY` environment variable is read *(7.6+)*. If neither is set, the one specified in the config file is used.

- **`-Timeout`**

Expand Down
4 changes: 4 additions & 0 deletions docs/reference/cli-reference/cli-ref-setapikey.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ ms.topic: reference

Saves an API key for a given server URL into `NuGet.Config` so that it doesn't need to be entered for subsequent push commands.

> [!TIP]
> Starting with NuGet 7.6, you can also set the `NUGET_API_KEY` environment variable to provide an API key for push operations without storing it in `NuGet.Config`.
> For more information, see [environment variables](cli-ref-environment-variables.md).

## Usage

```cli
Expand Down
4 changes: 4 additions & 0 deletions docs/reference/nuget-config-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ When using unencrypted passwords:

Stores keys for sources that use API key authentication, as set with the [`nuget setapikey` command](../reference/cli-reference/cli-ref-setapikey.md).

> [!NOTE]
> Starting with NuGet 7.6, the `NUGET_API_KEY` and `NUGET_SYMBOL_API_KEY` environment variables can also provide API keys for push operations.
> The command-line option takes precedence over the environment variable, and the environment variable takes precedence over keys stored in `NuGet.Config`.

| Key | Value |
| --- | --- |
| (source URL) | The encrypted API key. |
Expand Down