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

Allow reading PackageType from LockFile after restore #12934

Open
manio143 opened this issue Oct 11, 2023 · 1 comment
Open

Allow reading PackageType from LockFile after restore #12934

manio143 opened this issue Oct 11, 2023 · 1 comment
Labels
Functionality:Restore Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Type:Feature

Comments

@manio143
Copy link

NuGet Product(s) Involved

NuGet SDK

The Elevator Pitch

We're currently able to define custom package types for packages. We can search for those packages using the NuGet rest API, but from a C# project perspective they are just normal dependencies.
Documentation suggests we should write a custom tool to deal with those custom package types.

I'm currently investigating the option to use a custom package type to mark plugin packages for Stride with name StridePlugin. We use MSBuild to perform package restore on user's solution and then parse and read the project.assets.json using LockFileFormat. Despite PackageType property existing on the LockFileTargetLibrary it is not being populated within the lock file nor is it attempted to be read here:
https://github.com/NuGet/NuGet.Client/blob/67959d51c158942cdfc2aa5e14e37429931e6579/src/NuGet.Core/NuGet.ProjectModel/LockFile/LockFileFormat.cs#L507

Additional Context and Details

To provide a little more context - a Stride user references runtime dependencies in their project. If a library they reference requires a build time plugin we want to be able to read that from it's list of dependencies, detect which dependency is a plugin and load it.

Stride plugins may have a different target framework and would reference design/build time assemblies which the user wouldn't want to be included with their output - thus plugins need to be distinguishable and likely used in conjecture with developmentDependency.

@nkolev92 nkolev92 added Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Pipeline:Icebox and removed Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. labels Oct 30, 2023
@nkolev92
Copy link
Member

Hey @manio143,

PackageTypes haven't been used heavily in restore. The type was added there for the DotnetTool implementation, and I'd argue it's actually tech debt that was introduced there, as the PackageTypes of the LockFileTargetLibrary are never written in the assets file.

In general, the assets file tends to be a restore/build contract, so we'd normally add things that the build itself directly needs.

I do think that PackageType is something sensible to use for your scenario as you have a special package that's simply not usable without your component, but there are some caveats based on the current product behavior that you can read about in #10468.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:Restore Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Type:Feature
Projects
None yet
Development

No branches or pull requests

4 participants