Does Nuget support platform-specific dependencies?

I have a library that I want to create Nuget for which there is the following situation:

The library is compiled in different versions:

  • Silverlight 4.0
  • .Net 4.0
  • .net 3.5
  • Windows phone

Fortunately, all these platforms are supported by Nuget, so in the lib folder of my package I can create subfolders for each of these platforms, and Nuget will do everything correctly if the library is installed on any of these platforms.

The problem is that I have other dependencies that differ on the platform. For example: on Windows Phone, I need to enable a third-party zip library (wpSharpLibZip), but this dependency does not exist on other platforms that include zipping utilities.

Is this script supported in Nuget? I want the wpSharpLibZip dependency to exist only on the Windows Phone platform. Should I just create a separate package for the platform?


If this function does not exist, I can imagine that it is implemented something like this:

Changing the package manifest section to support:

<dependencies>
   <dependency id="Newtonsoft.Json" version="3.5.8" />
   <dependency id="wpSharpLibZip">
       <platform>Silverlight 4.0 - Windows Phone</platform>
   </dependency>
</dependencies>

Or in another way, there may be a separate separate .nuspec file inside each platform folder (under the lib folder), which could identify platform-dependent dependencies.

+3
source share
1 answer

A separate package for each set of dependencies. Dependencies is the package level. NuGet does not currently support this scenario and may not appear for a while, if at all.

UPDATE: NuGet 2.x, . . https://docs.nuget.org/create/nuspec-reference#specifying-dependencies-in-version-2.0-and-above

<dependencies> 
   <group>
      <dependency id="RouteMagic" version="1.1.0" />
   </group>

   <group targetFramework="net40">
      <dependency id="jQuery" />
      <dependency id="WebActivator" />
   </group>

   <group targetFramework="sl30">
   </group>
</dependencies>
+4

Source: https://habr.com/ru/post/1792144/


All Articles