【问题标题】:Building a nuget package that references a portable class library构建引用可移植类库的 nuget 包
【发布时间】:2014-04-13 01:38:57
【问题描述】:

我正在尝试构建一个安装可移植类库的 nuget 包,该类库本身依赖于可移植类库的集合。我可以创建包并毫无问题地安装它,但是当我运行安装了新包的应用程序时,.NET 4.5。类库测试项目,总是报如下异常:

threw exception: 
 System.IO.FileNotFoundException: Could not load file or assembly 
  'Microsoft.Data.Services.Client.Portable, Version=5.6.1.0, Culture=neutral, ...

我的 nuspec 文件,包含以下依赖项部分。

<dependencies>
  <group targetFramework="portable-net45+wp80+win">
    <dependency id="Microsoft.Bcl" version="1.1.6"  />
    <dependency id="Newtonsoft.Json" version="6.0.2" />
    <dependency id="Microsoft.Data.Services.Client" version="5.6.1" />
    <dependency id="Microsoft.AspNet.WebApi.Client" version="5.1.1" />
  </group>
</dependencies>

我过去创建了许多 nuget 包,但从未遇到过这个问题。我猜这与引用我正在创建的 PCL dll 中每个库的 PCL 版本有关,但我不知道如何让这个 nuget 正常工作。

我错过了什么?

【问题讨论】:

    标签: nuget nuget-package portable-class-library


    【解决方案1】:

    这看起来像是 Microsoft.Data.Services.Client NuGet 包的问题。它为可移植版本使用不同的程序集名称,就像 .NET Framework 和 Silverlight 版本一样。因此,您的可移植程序集是针对 Microsoft.Data.Services.Client.Portable.dll 编译的,但是当您的 NuGet 包安装到 .NET 项目中时,会改为引用 Microsoft.Data.Services.Client.dll。

    一般来说,像这样的包应该在所有平台上使用相同的程序集名称(不过,API 也需要在平台之间兼容)。

    【讨论】:

    • 那么我应该如何改变才能使 nuget 正常工作?
    • @JayTraband 你无能为力。您必须等待发布固定版本的 NuGet 包。
    • 您的意思是 Microsoft.Data.Services.Client.Portable nuget?
    • @JayTraband Microsoft.Data.Services.Client 包。它有一个名为 Microsoft.Data.Services.Client.Portable 的 DLL,这是不正确的。
    猜你喜欢
    • 1970-01-01
    • 2013-10-18
    • 1970-01-01
    • 2016-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-15
    相关资源
    最近更新 更多