Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet cli nuget does not support -k for passing apikey/auth for restore #8812

Open
anirudh83 opened this issue Nov 12, 2019 · 5 comments
Open
Labels

Comments

@anirudh83
Copy link

Currently, we are trying to restore from Private Nuget repo (Artifactroy) which requires authentication.
In order to do that we need to execute this comand :
dotnet restore -s ${ARTIFACTORY_FEED_URL} -k ${ARTIFACTORY_USER}:${ARTIFACTORY_PASS}
it looks like -k is not supported with dotnet restore

@nkolev92
Copy link
Member

The recommended approach for authenticate are plugins. See https://docs.microsoft.com/en-us/nuget/reference/extensibility/nuget-cross-platform-authentication-plugin.

Given that the plugins need a provider side action, the next best thing are creds in config file.

nuget.exe has the sources command for, which on windows will encrypt the PAT.

dotnet nuget sources is coming soon in #4126, but it's yet unclear whether the PATs will be encrypted on all platforms.

Given that information, personally I'd be in favor of that experience instead of adding a password option for dotnet restore, especially when considered that nuget.exe restore doesn't support one either.

@NuGet/nuget-client Thoughts?

@anirudh83
Copy link
Author

More context : We are using alpine based dotnet core images as our base image to run our dotnet core applications. nuget.config is fine for local, but in CI (gitlab) we can set the variables and pass them to nuget.exe .

@anirudh83
Copy link
Author

I guess fallback option could be to replace the credentials in nuget.config using something like sed in the CI agent, the values coming in from CI variables. But this doesnt look clean :(

@nkolev92
Copy link
Member

@anirudh83

NuGet supports environment variable expansion in nuget.config.

See related issue: #8662
Note that this issue just calls out that the docs are lacking, but the expansion does work.

@jholovacs
Copy link

This really seems like a pretty big gap to me. CI is usually set up using api keys, most CI tools recommend using it that way. But if the same CI tool can't restore a nuget package with an api key, it seems like a non-starter. Must there be multiple means of authenticating the same account in one system?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants