You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As package author how can I distinguish if my package is used as transitive or direct dependency?
A NuGet package gets used and shall behave differently if it’s used as a direct or a transitive dependency. E.g. some Property has to be extended if it is a direct dependency, but not if it is a transitive one. At the same time another Property has to be extended regardless if its direct or transitive.
I thought the build vs. buildTransitive folders (see MSDN) are what I need.
Here is a test scenario:
Assume I have a Project A which has a PackageReference to B, which depends on C. B and C are NuGet Packages.
Project A
└── Package B
├── build\B.props
├── buildTransitive\B.props
└── Package C
├── build\C.props
├── buildTransitive\C.props
A has a direct dependency to B and a transitive dependency to C
Expected behaviour:
Project A should be able to consume build/B.props from Package B and buildTransitive/C.props from Package C
Observed behaviour:
In the given example buildTransitive/B.props and buildTansitive/C.props are available in Project A.
As soon as a package has a package.props in the buildTransitive folder, then the package.props from the build folder is ignored.
Interestingly when I remove the buildTransive package props files, then both build package props will be available. But I am not able to get the desired behaviour.
Question:
I thought the build vs. buildTransitive folders (see MSDN) are what I need.
Basically, I would also be fine if I could distinguish the dependency type (direct vs. transitive), then I could add conditions on the properties within the package props.
Note: Custom targets or so in Project A are not desired. It shall be transparently provided through the NuGet packages. The package consumers shall not be forced to add custom logic.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Problem description
As package author how can I distinguish if my package is used as transitive or direct dependency?
A NuGet package gets used and shall behave differently if it’s used as a direct or a transitive dependency. E.g. some Property has to be extended if it is a direct dependency, but not if it is a transitive one. At the same time another Property has to be extended regardless if its direct or transitive.
I thought the build vs. buildTransitive folders (see MSDN) are what I need.
Here is a test scenario:
Assume I have a Project A which has a PackageReference to B, which depends on C. B and C are NuGet Packages.
A has a direct dependency to B and a transitive dependency to C
Expected behaviour:
Project A should be able to consume build/B.props from Package B and buildTransitive/C.props from Package C
Observed behaviour:
In the given example buildTransitive/B.props and buildTansitive/C.props are available in Project A.
As soon as a package has a package.props in the buildTransitive folder, then the package.props from the build folder is ignored.
Interestingly when I remove the buildTransive package props files, then both build package props will be available. But I am not able to get the desired behaviour.
Question:
I thought the build vs. buildTransitive folders (see MSDN) are what I need.
Basically, I would also be fine if I could distinguish the dependency type (direct vs. transitive), then I could add conditions on the properties within the package props.
Note: Custom targets or so in Project A are not desired. It shall be transparently provided through the NuGet packages. The package consumers shall not be forced to add custom logic.
Context:
Beta Was this translation helpful? Give feedback.
All reactions