Skip to content

Support nuget.config source credentials with env var expansion - #40

Merged
kzu merged 2 commits into
devlooped:mainfrom
snipervld:dev/nuget_credentials
Oct 23, 2026
Merged

kzu merged 2 commits into
devlooped:mainfrom
snipervld:dev/nuget_credentials

Conversation

@snipervld

@snipervld snipervld commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Adds support for packageSourceCredentials from nuget.config, so tools can be installed from private feeds.

<packageSourceCredentials>
  <My_x0020_Feed>
    <add key="Username" value="me" />
    <add key="ClearTextPassword" value="%FEED_PAT%" />
  </My_x0020_Feed>
</packageSourceCredentials>
  • Sent as basic auth, only to the source's own host.
  • Env vars in username and password are expanded.
  • Only ClearTextPassword is supported, not encrypted Password (iirc, native dnx on linux and macos doesn't support it).

@kzu

kzu commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Rather than inventing our own envvar resolution mechanism, couldn't we just implement https://learn.microsoft.com/en-us/nuget/consume-packages/consuming-packages-authenticated-feeds#credentials-in-environment-variables?

@kzu

kzu commented Oct 22, 2026

Copy link
Copy Markdown
Member

Or perhaps as a primary mechanism, with %...% documented as a proprietary fallback (which I'm not too fond of since it would break compatibility with dnx, which is an explicit goal)

@snipervld

Copy link
Copy Markdown
Contributor Author

Rather than inventing our own envvar resolution mechanism, couldn't we just implement https://learn.microsoft.com/en-us/nuget/consume-packages/consuming-packages-authenticated-feeds#credentials-in-environment-variables?

Ok, I'll take a look. Btw, invented envvar expansion is just a Environment.ExpandEnvironmentVariables.

Or perhaps as a primary mechanism, with %...% documented as a proprietary fallback (which I'm not too fond of since it would break compatibility with dnx, which is an explicit goal)

If I remember correctly, dnx (and dotnet nuget) resolve these %...% out of the box (that's why I picked them - in docker dotnet nuget expanded them).

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@snipervld

Copy link
Copy Markdown
Contributor Author

@kzu, done - added support for NuGetPackageSourceCredentials_{name} env vars; they take precedence over nuget.config credentials (just like nuget/dnx).

P.S. For %...%: the doc mentions it "The username and plain text password in a nuget.config file can use an environment variable by adding % to the beginning and end of the environment variable name", so it's a documented feature.

@kzu
kzu enabled auto-merge (squash) October 23, 2026 16:05
@kzu
kzu merged commit 0fd4d87 into devlooped:main Oct 23, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants