Reputation: 23934
I am building a NuGet package that references the Microsoft CommonServiceLocator assembly.
There are two versions of the Microsoft CommonServiceLocator out there:
My project is a Portable Class Library but, because it's sometimes used with Enterprise Library, I need to sort of "conditionally" reference the portable version so there's no conflict.
I see the new "group" feature in the NuGet docs showing how to specify dependencies in your .nuspec file and I think that will do what I want, but I'm not sure how to test it.
Here's what I think I need to do and I'm hoping someone can validate my approach or point me in the right direction:
<dependencies>
<group>
<!-- Always include regardless of target framework -->
<dependency id="Autofac" />
</group>
<group targetFramework="net40">
<!-- Also include the full CSL if it's full framework -->
<dependency id="CommonServiceLocator" />
</group>
<group targetFramework="portable-win+sl50+wp8">
<!-- Otherwise include the Portable CSL -->
<dependency id="Portable.CommonServiceLocator" />
</group>
</dependencies>
Specifically...
targetFramework
syntax right? I can't find any examples, so I don't know if the +
delimited mechanism is right or if it should be comma-delimited.Upvotes: 16
Views: 8125
Reputation: 2233
Yeah, that's pretty much correct. Details on portable framework names can be found here http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package#Framework_Names
One more thing I found, since win+sl50+wp8 by default includes net45 you might want to include it so that this dependency group gets installed.
Upvotes: 7