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
Project A has a dependency on B, which in turn depends on TaskParallelLibrary, but only for target platform .Net 3.5. TaskParallelLibrary is an indirect dependency only and not mentioned in paket.references or or paket.dependencies (but is mentioned in paket.lock).
The nuspec dependencies of B look like the following:
The first one for v3.5 seems to be correct, but the latter should not be there, as it causes TaskParallelLibrary to be referenced in v4.0 and newer as well.
Note that the nuspec reference is quite unclear if not wrong on what happens if multiple groups specify a compatible target framework. The behavior of NuGet itself is equivalent to the /lib/net40 style folders, i.e. the "best" fit wins and the others are ignored.
From the nuspec reference: "All dependencies inside a group are installed together if the target framework is compatible with the project's framework profile.". This could be interpreted in a way that all groups with a compatible target framework should be installed - and the current Paket behavior correct. However, that would make it impossible to restrict to specific versions only (= constraint) and is not how NuGet behaves.
Just noticed this is also used in the Octokit nuspec testfile where the dependency on Microsoft.Net.Http is skipped on .Net 4.5+ and .Net-Core 4.5+ but used in all other configurations. Might get ugly to map this with Choice/When in MsBuild.
Most cases where such monkey-patching is needed is bad packages not restricting their target platforms properly, so ideally this could be fixed there instead. But this is not always possible unfortunately.
There is no way to do this without computing the whole installation model in advance. This will probably improve some other things too. But it will take a while.
It's interesting that there seem to be two ways of modelling conditional NuGet package dependencies -
either the .nuspec declares groups and then only adds a <dependency to a subset (the case you're talking about)
there's always a dependency, but sometimes it nulls itself out (the Microsoft.Net.Http model)
It seems the latter is more sustainable or downstream packages are not respecting the Law of Demeter (though it's tempting if System.Threading only needs to be shimmed in net35)
@cdrnet#145 and #146 address the two concerns you note re octokit
@forki (or @ilkerde) Can you explain what you mean by strict mode wrt this issue? (I'd like to understand it for #154). I've come across it in the docs but to be honest they didnt speak to me and I hence wasnt able to arrive a sufficient understanding to be able to verify whether it was explained wlll or whether I'm just missing a concept (or 3!)
@bartelink I don't quite understand how the mentioned Microsoft.Net.Http model works for specifying conditional dependencies (where I cannot modify the packages I depend on). How would I have to declare my dependencies in my nuspec in the following similar case (other than the dependency groups)?
On .Net 3.5 depend on FSharp.Core.4.3.0.0.Microsoft.Signed
Evereywhere else depend on FSharp.Core.Microsoft.Signed
@cdrnet No, not suggesting one can always be expressed in terms of the other.
Just saying they use a Null Object pattern in some cases.
I agree your example def can not be expressed that way.
The specific thing I was referring to is that in 4.0 there is a DLL whereas in 4.5 its in core FW. They could have extracted a package for 4.0 and put in a conditional dep but they have not yet. (They have quite a few DLLs in there and arguably they should split to avoid having to put so many redundant copies of things). But obviously that leads to stacks of packages. Old DRY vs Rule of 2-3+ thing etc.
Activity
cdrnet commentedon Sep 20, 2014
Note that the nuspec reference is quite unclear if not wrong on what happens if multiple groups specify a compatible target framework. The behavior of NuGet itself is equivalent to the /lib/net40 style folders, i.e. the "best" fit wins and the others are ignored.
From the nuspec reference: "All dependencies inside a group are installed together if the target framework is compatible with the project's framework profile.". This could be interpreted in a way that all groups with a compatible target framework should be installed - and the current Paket behavior correct. However, that would make it impossible to restrict to specific versions only (= constraint) and is not how NuGet behaves.
cdrnet commentedon Sep 20, 2014
Verbose Output:
forki commentedon Sep 21, 2014
didn't know this stuff exists ;-)
will look into it.
cdrnet commentedon Sep 21, 2014
Thanks!
Just noticed this is also used in the Octokit nuspec testfile where the dependency on
Microsoft.Net.Httpis skipped on .Net 4.5+ and .Net-Core 4.5+ but used in all other configurations. Might get ugly to map this with Choice/When in MsBuild.forki commentedon Sep 21, 2014
it already is a big pain....
forki commentedon Sep 21, 2014
boah. this thing is really really ugly.
bartelink commentedon Sep 21, 2014
Related stuff at end of #68
forki commentedon Sep 21, 2014
this is completely fucked up. and I don't even see a way to solve this with @ilkerde's strict mode.
cdrnet commentedon Sep 21, 2014
Most cases where such monkey-patching is needed is bad packages not restricting their target platforms properly, so ideally this could be fixed there instead. But this is not always possible unfortunately.
forki commentedon Sep 21, 2014
after think about this:
There is no way to do this without computing the whole installation model in advance. This will probably improve some other things too. But it will take a while.
So please manually edit to:
Notice I also remoded the paket flag. This will make the nodes for paket to not touch it again.
cdrnet commentedon Sep 21, 2014
Yes, this will work for me as workaround. Thanks!
Paket: workaround for fsprojects/Paket#140
bartelink commentedon Sep 25, 2014
It's interesting that there seem to be two ways of modelling conditional NuGet package dependencies -
.nuspecdeclares groups and then only adds a<dependencyto a subset (the case you're talking about)Microsoft.Net.Httpmodel)It seems the latter is more sustainable or downstream packages are not respecting the Law of Demeter (though it's tempting if System.Threading only needs to be shimmed in
net35)@cdrnet #145 and #146 address the two concerns you note re octokit
Base NuGet Lib Reference generation on Lib Folders #145 "Base NuGet Lib Reference generation on Lib Folders" deals processing the
Microsoft.Net.HttpnugetSupport (Conditional) Framework Assembly References #146 "Support (Conditional) Framework Assembly References" is a more exotic variant of the octokit:
@cdrnet How about renaming this issue to "support group-specific dependencies" (or calving a new issue and closing this)
@forki (or @ilkerde) Can you explain what you mean by strict mode wrt this issue? (I'd like to understand it for #154). I've come across it in the docs but to be honest they didnt speak to me and I hence wasnt able to arrive a sufficient understanding to be able to verify whether it was explained wlll or whether I'm just missing a concept (or 3!)
[-]Conditional indirect dependencies (TargetFramework) not respected[/-][+]Support group-specific dependencies[/+]cdrnet commentedon Sep 27, 2014
@bartelink I don't quite understand how the mentioned
Microsoft.Net.Httpmodel works for specifying conditional dependencies (where I cannot modify the packages I depend on). How would I have to declare my dependencies in my nuspec in the following similar case (other than the dependency groups)?bartelink commentedon Sep 27, 2014
@cdrnet No, not suggesting one can always be expressed in terms of the other.
Just saying they use a Null Object pattern in some cases.
I agree your example def can not be expressed that way.
The specific thing I was referring to is that in 4.0 there is a DLL whereas in 4.5 its in core FW. They could have extracted a package for 4.0 and put in a conditional dep but they have not yet. (They have quite a few DLLs in there and arguably they should split to avoid having to put so many redundant copies of things). But obviously that leads to stacks of packages. Old DRY vs Rule of 2-3+ thing etc.
cdrnet commentedon Sep 27, 2014
Ah ok, thanks for the clarification.
forki commentedon Nov 19, 2014
the current Paket version generates the following lockfile for your case:
So it should only reference TaskParallelLibrary for .NET 3.5. Can you check if it works?
cdrnet commentedon Nov 23, 2014
It seems to work, the resulting project file looks good to me! Thanks!
There is now an issue with a group-specific framework assembly reference, but I'll open a new issue on this.
Create regression test for #140
Create regression test for #140