GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Set the global credential provider #1018 by aarondandy · Pull Request #1021 · scriptcs/scriptcs

Conversation

@aarondandy

@aarondandy aarondandy commented Apr 13, 2015

Copy link
Copy Markdown
Contributor

Fix for #1018 that sets the global credential provider. This allows the NuGet HttpClient to use the credentials stored in NuGet.Config .

I tested this by editing my %APPDATA%\NuGet\NuGet.Config file to use packageSourceCredentials for our myget feeds, specifically our nuget mirror. This file has Username and Password credentials for some of the MyGet feeds and nuget.org is disabled using:

  <disabledPackageSources>
    <add key="https://www.nuget.org/api/v2/" value="true" />
  </disabledPackageSources>

I produced two builds using build.cmd, one from before the change and one from after and watched what they did using Fiddler. The build before the change would try the various feeds once and get a 401 response for each then just give up. The build after the change would retry with credentials following the 401 response getting 404s for most and a 200 for the package on the mirror feed. More importantly the build with the fix actually installed some packages too!

Regarding the approach, to my knowledge setting this global property is the only way to configure the NuGet HttpClient to use these credentials. It kind of makes me wonder if this should be fixed in NuGet.Core instead of here in script CS but I guess that is up to you all and those working on NuGet v2.

The location for this one line was chosen because of the proximity to the PackageSourceProvider instance. I would like to see this code in Initialize but I don't think setting it multiple times should hurt and I also don't see the GetRepositorySources method called anywhere except for Initialize.

Some things to note:

  • No tests were created for this change. I really don't know a practical way to create a test for this change.
  • The code that was edited does not appear to have any existing coverage (using NCrunch).
  • I have no test failures before or after this change using build.cmd.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@aarondandy
Fix for #1018 that sets the global credential provider
66d6b29
@adamralph adamralph added the child PR label Apr 16, 2015
@adamralph adamralph changed the title Fix for #1018 that sets the global credential provider Set the global credential provider #1018 Jul 29, 2015
@aarondandy

aarondandy commented Nov 30, 2015

Copy link
Copy Markdown
Contributor Author

This may be an alternative way to solve this problem in the future if scriptcs can allow configuration for it: http://docs.nuget.org/Consume/Credential-Providers

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@glennblock

glennblock commented Jul 29, 2016

Copy link
Copy Markdown
Contributor

@scriptcs/core thoughts?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@glennblock

glennblock commented Jul 29, 2016

Copy link
Copy Markdown
Contributor

This looks reasonable to me as long as it does not affect existing users that are not requiring credentials.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@glennblock
glennblock merged commit ffcd2ff into scriptcs:dev Sep 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

child PR

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@aarondandy @glennblock @adamralph
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.