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

Feature request: Non-transitive package dependencies? #3964

Closed
ig-sinicyn opened this issue Nov 17, 2016 · 5 comments
Closed

Feature request: Non-transitive package dependencies? #3964

ig-sinicyn opened this issue Nov 17, 2016 · 5 comments

Comments

@ig-sinicyn
Copy link

ig-sinicyn commented Nov 17, 2016

VS2015 upd3, nuget 3.5 (latest one), .net4.6 framework project.

Use case:
I have a package X depending on third-party package Y. By default (Visual Studio 2015 Upd3 + nuget 3.5) any project referencing to package X will be updated with reference to package Y too. The issue is, customers of X do not need reference to Y at all, as API of package Y is not and should not be exposed to customers. There should be a way to mark such dependencies.

Expected implementation of the feature:

  1. X.nuspec, the Package Y is included as
   <dependency id="PackageY" version="1.2.3" private=true />

(private is just a placeholder, have no idea for better name).

  1. In customer project: after adding reference to package X, content of package Y should be copied into output folder on build, but package Y should not be added into project references.

Possible workarounds:
Theoretically we can include sources of the infrastructure package Y into our project X (in our case both projects are opensource under MIT license) but I'd prefer to use more or less standard approach.

Why we need it:

  • The case we're investigating right now: we have a nuget package with test helper that ensures that PDB files matches to the sources (references Microsoft.DiaSymReader package). We do not want all our test projects to reference Microsoft.DiaSymReader assembly.

  • More or less theoretical one (not an issue for now but will be a problem if the project will be pushed into production): custom script engine that uses Roslyn to compile and run the scripts. We do not want references to the Roslyn assemblies in all projects that will use our script engine.

Latter case is much worse as we cannot merge roslyn sources into our project, obviously, and cannot distribute roslyn binaries as a part of our package, too.

Real-world example:
There's a package with exactly same issue: Benchmark.Net.
Create a new project targeting .net 4.6+, add a reference to Benchmark.Net aand:

references

Also asked on stackoverflow.

@davidfowl
Copy link
Member

This is supported in project.json which is becoming the new package reference node in csproj. Packages can also express this today with include/exclude flags on dependency nodes. This wiki article describes those features https://github.com/NuGet/Home/wiki/%5BSpec%5D-Managing-dependency-package-assets.

The reason it's so granular is because you want transitivity for runtime, but not compilation. You get that full expressiveness with these flags.

Unfortunately, this doesn't work with the way packages.config does things...

@ig-sinicyn
Copy link
Author

@davidfowl Great news to hear!

Packages can also express this today with include/exclude flags on dependency nodes

The https://github.com/NuGet/Home/wiki/%5BSpec%5D-Managing-dependency-package-assets
states that the following is supported:

<dependencies>
  <group>
    <dependency id="packageB" version="1.0.0" include="all" />
  </group>
</dependencies>

but official docs has no mention of include / exclude and do not clarify meaning of include flags. Is it supported by current VS nuget package manager?

If yes: what flag should be used for my use case?

   <dependency id="PackageY" version="1.2.3" exclude="compile" />

, right?

@ig-sinicyn
Copy link
Author

UPD: Looks like duplicate to #3052

I'm still interested in getting an answer though : )

@davidfowl
Copy link
Member

If yes: what flag should be used for my use case?

Yes.

/cc @emgarten You guys should update the official docs

@emgarten
Copy link
Member

The docs for this are being tracked here #4551

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

No branches or pull requests

3 participants