0

In a NuGet package, in its .nuspec file, the package dependencies are specified on a per-target framework basis. E.g., in the System.Collections.NonGeneric package, here are its TF dependencies:

<dependencies>
  <group targetFramework="MonoAndroid1.0" />
  <group targetFramework="MonoTouch1.0" />
  <group targetFramework=".NETFramework4.6" />
  <group targetFramework=".NETStandard1.3">
    <dependency id="System.Diagnostics.Debug" version="4.3.0" exclude="Compile" />
    <dependency id="System.Globalization" version="4.3.0" />
    <dependency id="System.Resources.ResourceManager" version="4.3.0" exclude="Compile" />
    <dependency id="System.Runtime" version="4.3.0" />
    <dependency id="System.Runtime.Extensions" version="4.3.0" exclude="Compile" />
    <dependency id="System.Threading" version="4.3.0" exclude="Compile" />
  </group>
  <group targetFramework="Xamarin.iOS1.0" />
  <group targetFramework="Xamarin.Mac2.0" />
  <group targetFramework="Xamarin.TVOS1.0" />
  <group targetFramework="Xamarin.WatchOS1.0" />
</dependencies>

It of course doesn't contain all TFMs, so my question: What happens if my calling application is targeting .NET Framework 4.6.1 (.NET Standard 1.4)? Will the 6 System.* packages still need to be downloaded, since .NET Standard 1.4 >= 1.3? Or since I am not specifically targeting a .NET Standard 1.3 TFM, there are no dependencies for my project? Thanks for the clarification.

Conrad
  • 2,197
  • 28
  • 53

1 Answers1

0

NuGet always chooses the "closest" (highest version that is less than or equal) target framework. It doesn't have to be an exact match. So, it doesn't matter that the package doesn't specify netstandard1.4 dependencies. It lists netstandard1.3, so NuGet will select it if it's the best match.

However, best match also considers Target Framework Identifier. So, a .NET Framework 4.6.1 project is going to match the .NET Framework 4.6 dependency group, so no .NET Standard dependency group will be considered.

zivkan
  • 12,793
  • 2
  • 34
  • 51