【发布时间】:2012-12-03 17:26:59
【问题描述】:
我正在构建一个引用 Microsoft CommonServiceLocator 程序集的 NuGet 包。
Microsoft CommonServiceLocator 有两个版本:
- CommonServiceLocator - 针对完整的 .NET 框架,并被 Microsoft EnterpriseLibrary 组件引用。
- Portable.CommonServiceLocator - 包含完整版 CommonServiceLocator 和 the recently released Portable Class Library version。
我的项目是一个可移植类库,但因为它有时与企业库一起使用,所以我需要“有条件地”引用可移植版本,这样就不会有冲突。
- 如果目标框架是完整的 .NET 4.0/4.5,请使用原始 CommonServiceLocator 包,这样人们也可以使用企业库位(也引用 CommonServiceLocator 包)。
- 如果目标框架是可移植的(或其他),请使用 Portable.CommonServiceLocator 包。
I see the new "group" feature in the NuGet docs showing how to specify dependencies in your .nuspec file 我认为这会做我想要的,但我不知道如何测试它。
这是我认为我需要做的事情,我希望有人可以验证我的方法或为我指明正确的方向:
<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>
具体...
-
我的
targetFramework语法对吗?我找不到任何示例,所以我不知道+分隔机制是否正确,或者是否应该使用逗号分隔。 - 默认组是否有效? 具有未指定目标框架的组 - 是否会始终包含在内,还是我需要在每个组中复制/粘贴它?
【问题讨论】: