I've created a private NuGet server (https://github.com/ai-traders/liget) which requires an API key to upload packages but not to download/restore them.
I am sure I can enhance the code of the server to mandate the use of an API Key when restoring, but the investigation I've done (mainly googling) hasn't yielded any examples of how an API Key can be specified for dotnet restore
and the Visual Studio NuGet UI doesn't appear to allow it.
Is there a way of specifying an API Key for dotnet restore or is the only option to include it as a query parameter (e.g. https://mynuget.com?apikey=<API_KEY>)? Ideally I'd like to put the API Key in the header.
I discovered that you can't do this with an API key, but you can setup basic authentication on the NuGet server and use:
dotnet nuget add source <nuget server> --name <name> --username <user> --password <password> --store-password-in-clear-text
This also works with Visual Studio. You'll get a dialog to enter the user name and password when you configure a new NuGet server.