NuGet / Home

Repo for NuGet Client issues
Other
1.49k stars 249 forks source link

Add support for patching NuGet Packages / Sourced-base mode for NuGet #13550

Open nkosi23 opened 2 weeks ago

nkosi23 commented 2 weeks ago

NuGet Product(s) Involved

NuGet.exe, NuGet SDK

The Elevator Pitch

I've recently contributed to a rust project and have to admit that as a long-time .NET developer, their package management system (named cargo) has spoiled me. I've been blown away by how modern the development experience felt after years of mainly using NuGet and npm.

With cargo, one can patch packages (that they call crates) as easily as by pointing to a git repository at a specific branch and/or commit, or by pointing to the local file system. And such overrides can apply to either a specific project, or to all the projects of what we would call a solution in the .NET world. Example for the uuid package:

[patch.crates-io]
uuid = { git = 'https://github.com/uuid-rs/uuid.git' }

One can I also do the same to change the source of dependencies:

[dependencies]
rand = { git = "https://github.com/rust-lang-nursery/rand" }

This feature is great because it makes it very easy for people to modify packages to accommodate their needs, or fix bugs, and then contribute their code back (or maintain their local fork). It creates a vibrant community culture where people do not hesitate to get their hands dirty and contribute because doing so is made so easy. I felt that I had more control over the dependencies used by the system instead of being forced to treat them as black boxes.

NuGet has not changed meaningfully for over a decade, but at the same time there exists a huge number of open-source .NET projects whose github URL is referenced on nuget.org. I therefore propose adding a source-based mode to Nuget having such patching capability.

While I appreciate that such a feature is major and will not be able to be implemented overnight, I believe that it should at the very least be present on the roadmap so that NuGet remains state-of-the-art instead of falling behind. This source-based mode will also constitute a platform for many other features not possible using the binary-only approach.

Additional Context and Details

No response

nkolev92 commented 2 weeks ago

The biggest difference is that source packages aren't a common thing in .NET, so such implementation would require all packages to be buildable with a specific command. The build times would also increase exponentially.

Related: https://github.com/NuGet/Home/issues/2316

Note that through package source mapping, you can control the provenance of your packages.