Could you log a bug so it is tracked? One way to do this would be to allow an optional framework to be specified on the <dependency> tag, just like we're planning to do with our new GAC reference feature.
Although I wonder if a simpler solution is to just not fail in this case. So basically:
- When the primary package you're trying to install doesn't have anything for your framework, fail
- But when that happens for for dependent package, allow the dependent package not to bring in anything
@techekon: can you paste the output with the error that you're getting from the NuGet console?
I think I found a issue logged in there already for the general case of having dependencies with a target framework specified, http://nuget.codeplex.com/workitem/697
This is the error and I think it is a correct error:
Install-Package : Unable to find assembly references that are compatible with the target framework '.NETFramework,Version=v3.5'.
At line:1 char:16
+ install-package <<<< NET35_W_40_DEP
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.Cmdlets.InstallPackageCmdlet
If you ignore it, sure it would work for my back ported version but I don't think you can assume that was then intention. Also what if my backported version requires an additional assembly then the 4.0 version is going to end up having unnecessary package
Supporting Multiple .NET Framework Versions and Profiles
Many libraries target a specific version of the .NET Framework. For example, you might have one version of your library that’s specific to Silverlight, and another version of the same library that takes advantage of .NET Framework
4 features. You do not need to create separate packages for each of these versions. NuGet supports putting multiple versions of the same library in a single package keeping them in separate folders within the package.
If a single package is supposed to support multiple target frameworks, it seems logical that you should be able to specify it on dependencies as well the included libs and it should probably follow the same logic as the assemblies included package in
the package. So if you specify net40 on a dependency that should be the only dependency for a net40 installation and if you have 2nd dependency for a general case but it should be included in a net40 too you have specify the dependency twice once with net40
and once without.