Skip to content

Introduce package downloading feature to dotnet - #14495

Merged
Nigusu-Allehu merged 8 commits into
devfrom
dev-nyenework-install
Oct 28, 2025
Merged

Nigusu-Allehu merged 8 commits into
devfrom
dev-nyenework-install

Conversation

@Nigusu-Allehu

@Nigusu-Allehu Nigusu-Allehu commented Aug 20, 2025 •

Copy link
Copy Markdown
Member

This document proposes adding a dotnet package download command to the .NET CLI.

Rendered: https://github.com/NuGet/Home/blob/dev-nyenework-install/accepted/2025/dotnet-package-download.md

@Nigusu-Allehu
Nigusu-Allehu requested a review from a team as a code owner August 20, 2025 17:10
@Nigusu-Allehu Nigusu-Allehu self-assigned this Aug 20, 2025
Comment thread accepted/2025/dotnet-package-install.md Outdated
Comment thread accepted/2025/dotnet-package-install.md Outdated
Comment thread accepted/2025/dotnet-package-install.md Outdated
Comment thread accepted/2025/dotnet-package-install.md Outdated
Comment thread accepted/2025/dotnet-package-install.md Outdated
Comment thread accepted/2025/dotnet-package-install.md Outdated
Comment thread accepted/2025/dotnet-package-install.md Outdated
Comment thread accepted/2025/dotnet-package-install.md Outdated
Comment thread accepted/2025/dotnet-package-install.md Outdated
Comment thread accepted/2025/dotnet-package-install.md Outdated
Comment thread accepted/2025/dotnet-package-install.md Outdated
Comment thread accepted/2025/dotnet-package-install.md Outdated
Comment thread accepted/2025/dotnet-package-install.md Outdated
Comment thread accepted/2025/dotnet-package-install.md Outdated
Comment thread accepted/2025/dotnet-package-install.md Outdated
Comment thread accepted/2025/dotnet-package-install.md Outdated
Comment thread accepted/2025/dotnet-package-install.md Outdated
* `--dependency-version <policy>`: Controls how versions of dependencies are selected when a version range is specified.
Values: Lowest(default), HighestPatch, HighestMinor, and Highest.
* `--no-audit`: opts out of vulnerability auditing. Be default it is on.
* `--allow-insecure-connections`: allows downloading from http sources(insecure).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion would be to avoid adding all of these options everywhere.
There are ways to do it in the nuget.config and we'd respect that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this command will be used primarily in CI scenarios, I think having this option is critical. In cases where a dynamic source is required, relying on a nuget.config file can be cumbersome. For example, users encountered similar challenges with the push command, as noted in #14047.

Comment thread accepted/2025/dotnet-package-install.md Outdated
Comment thread accepted/2025/dotnet-package-install.md Outdated
@aortiz-msft
aortiz-msft requested a review from seaniyer August 22, 2025 18:20
@aortiz-msft

Copy link
Copy Markdown
Contributor

I thought dotnet was moving from nouns to verb. IOW, from dotnet package install to dotnet install . How does that fit with this command? @baronfel, is that your understanding as well?

@baronfel

Copy link
Copy Markdown

No, the other way around. We prefer nouns in order to group actions by the kind of thing they act upon. In this case 'dotnet package install' is aligned with the overall guidance (though as others note in the comments already we may discuss the use of install compared to other terms).

Comment thread accepted/2025/dotnet-package-install.md Outdated

Currently, the only way is either using `nuget.exe` or creating dummy projects with `dotnet restore`.

A `dotnet package install` improves developer productivity.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have links to GitHub issues or FeedbackTickets that we can add here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the original issue is linked at the top of the page: #12513. Do we also have other GitHub issues or Feedback Tickets that we should add here?

Comment thread accepted/2025/dotnet-package-install.md Outdated
@Nigusu-Allehu Nigusu-Allehu changed the title Introduce dotnet package install Introduce package downloading feature to dotnet Aug 28, 2025

@nkolev92 nkolev92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, my consideration is audit.

If people feel really strongly about it, I'm ok with it,

Comment thread accepted/2025/dotnet-package-download.md Outdated
Comment thread accepted/2025/dotnet-package-download.md Outdated
@Nigusu-Allehu

Copy link
Copy Markdown
Member Author

Hey @seaniyer , any feedback on this PR?

@seaniyer

seaniyer commented Sep 24, 2025 •

Copy link
Copy Markdown

Hey @seaniyer , any feedback on this PR?

Thanks for sharing @Nigusu-Allehu. Looks good to me! I am wondering if we have any user input that MVP scope with no dependency downloads is enough for real-world use.

baronfel
baronfel previously approved these changes Sep 24, 2025
Comment thread accepted/2025/dotnet-package-download.md
Comment thread accepted/2025/dotnet-package-download.md Outdated
Comment thread accepted/2025/dotnet-package-download.md Outdated
@Nigusu-Allehu

Copy link
Copy Markdown
Member Author

Hey @seaniyer , any feedback on this PR?

Thanks for sharing @Nigusu-Allehu. Looks good to me! I am wondering if we have any user input that MVP scope with no dependency downloads is enough for real-world use.

The decision was based on the user discussion from #12513 and in hopes of keeping the first iteration simple and reliable. However, if we get signal from users on scenarios where the current implementation comes short we will update the design as per.

Comment thread accepted/2025/dotnet-package-download.md Outdated
Comment thread accepted/2025/dotnet-package-download.md Outdated
Comment thread accepted/2025/dotnet-package-download.md
@Nigusu-Allehu
Nigusu-Allehu requested a review from nkolev92 October 9, 2025 17:40
nkolev92
nkolev92 previously approved these changes Oct 9, 2025

## Explanation

### Command Overview

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we ever discuss how PackageSourceMapping integrates with dotnet package download?

I think dotnet tool install is supposed to support it dotnet/sdk#41871 and it might've regressed.

Think we need to support source mapping in package download too.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! We did not discuss it. But I also think it is something we should support

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


* Populating internal or offline feeds.
* CI/CD workflows that consume `.nupkg` artifacts directly.
* **Cross-platform builds** where many customers today rely on `nuget.exe install` in CI scripts running on Linux or macOS, forcing them to install Mono just to get this functionality.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nuget install is a bit sloppy with how it handles package source mapping.
My testing gave me

Package 'Newtonsoft.json 13.0.4' is not found in the following primary source(s): 'https://api.nuget.org/v3/index.json,C:\Program Files (x86)\Microsoft SDKs\NuGetPackages'. Please verify all your online package sources are available (OR) package id, version are specified correctly.

At best, the error message isn't giving me a clear understanding of the problem (likely the logic finding the unmapped package is happening later than other commands like Restore). At worst, I wonder if install is trying to retrieve the package from the source first, then failing due to PSM being enabled.

Comment on lines +38 to +39
--allow-insecure-connections Allows downloading from HTTP sources.
--configfile <path> Path to a NuGet.config to use.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it weird that some commands support both config files and override flags like --source, etc.
It makes it hard to decide here if we should also have some --ignore-package-source-mappings or similar - but my opinion is we should either use a config or use the CLI options. Mixing the concepts is likely confusing and error-prone.

Perhaps we can error if --configFile is specified in addition to any other configuration related option?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not a bad idea at all, but please compare and contrast this proposed behavior against all of the other dotnet CLI commands that interact with the NuGet config file and that have explicit source management flags.

We need to bias very hard in the direction of consistency with the rest of the CLI. Anytime there's a command that behaves inconsistently with the rest of the CLI surface area we get a long tail of issues and confusion from end users.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that --source option and nuget.config are designed to complement each other in most of our commands.
Users can define their package sources through configuration files, but in dynamic environments: such as CI scenarios they may prefer to specify sources directly via the --source argument in scripts.

In other cases, when users already have multiple sources configured in their nuget.config but want to target one specifically, they can run --source <sourceName> to select it from their existing configuration.

In terms of precedence:

  • The --source option always takes priority over sources(replaces them basically) defined in nuget.config.

  • When --source <packageSource> is used, the CLI first checks whether the given value corresponds to a named source in the configuration file.

    • If it does, that configured source is used.
    • Otherwise, it’s treated as a direct source URI.
  • If --source is not specified, the CLI falls back to the sources defined in the user’s configuration files.

This pattern is consistent across commands like dotnet nuget push, dotnet package search, and others.

When package source mapping is involved:

  • If --source <packageSource> is specified, the CLI should follow the same behavior as above resolving the named source if present or treating it as a URI. In this case, package source mapping is not applied.
  • If --source is not specified, the CLI reads the configuration file and uses package source mapping to determine the appropriate source.

For example, dotnet tool install does support package source mapping. However, in my testing, I observed a bug where the --source option is ignored when a nearby nuget.config file is present, and I’ve reported this issue for further investigation dotnet/sdk#51412.

When it comes to the package download, command I think we should follow the same pattern too.

  • If --source is specified, the CLI should follow the same behavior as above: resolving the named source if present or treating it as a URI. In this case, package source mapping should not be applied.

  • If --source is not specified, the CLI should read the configuration file and use package source mapping to determine the appropriate source.

What do you think @nkolev92

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for me.

@Nigusu-Allehu

Copy link
Copy Markdown
Member Author

nkolev92
nkolev92 previously approved these changes Oct 24, 2025
Comment on lines +38 to +39
--allow-insecure-connections Allows downloading from HTTP sources.
--configfile <path> Path to a NuGet.config to use.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for me.

@aortiz-msft aortiz-msft left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to deliver the functionality under the "Deferred (not in MVP)" section at some point in the future? If not, we should remove items from that section or the section itself altogether. (Deferred implied intent to deliver later.)

@Nigusu-Allehu

Copy link
Copy Markdown
Member Author

Do we want to deliver the functionality under the "Deferred (not in MVP)" section at some point in the future? If not, we should remove items from that section or the section itself altogether. (Deferred implied intent to deliver later.)

I have removed the section.

@aortiz-msft aortiz-msft left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address comment on deferred improvements.

@aortiz-msft aortiz-msft left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@Nigusu-Allehu
Nigusu-Allehu merged commit f7c6093 into dev Oct 28, 2025
1 check passed
@Nigusu-Allehu
Nigusu-Allehu deleted the dev-nyenework-install branch October 28, 2025 17:48
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.

8 participants