开发者

Does Nuget support dependancies which are tied to a particular platform?

I have a library which I want to create a Nuget package for which has the following situation:

The library compiles to different versions:

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

Luckily all of these platforms are supported by Nuget so in the lib f开发者_StackOverflow社区older of my package I can create sub folders for each of these platforms and Nuget will do the right thing when the library is installed on any of those platforms.

The problem is I have some other dependencies which differ by platform. For example: On the Windows Phone I need to include a 3rd party zip library (wpSharpLibZip) but this dependency does not exist on the other platforms which have zipping utilities included.

Is this scenario supported in Nuget? I want to be able to have the wpSharpLibZip dependency to only exist on the Windows Phone platform. Do I have to just create a separate package per platform?


If this feature doesn't exist I could imagine it being implemented something like:

Changing the section of the package manifest to support:

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

Or another way could be to allow for a seperate .nuspec file inside of each platform folder (under the lib folder) which could spell out platform specific dependencies.


Separate package for each different dependency set. Dependencies are package level. NuGet doesn't support this scenario at this time and may not for awhile if at all.

UPDATE: Dependencies have groups since NuGet 2.x, so you can set dependencies this way. See https://docs.nuget.org/create/nuspec-reference#specifying-dependencies-in-version-2.0-and-above for details

<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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜