【问题标题】:TFS 2013 Build - Newtonsoft.Json - Visual Studio 2015TFS 2013 构建 - Newtonsoft.Json - Visual Studio 2015
【发布时间】:2015-09-30 09:06:53
【问题描述】:

更新: 因此,我登录到服务器并使用 VS 2013 打开项目。我单击了解决方案上下文菜单上的“启用 nuget 包还原”。现在,它建立在服务器上。问题是,我不知道如何在 VS 2015 中做同样的事情。没有右键菜单。我已经在选项中启用了“允许自动包恢复”。 -结束更新

我在 Visual Studio 2015 中有一个项目。我可以在本地计算机上成功构建和运行它。它使用从 Nuget 获得的 Newtonsoft.Json (JSON.net)。当我签入并且我的持续集成构建在构建服务器上运行时,它会引发一个异常,它无法找到 JSON.net 程序集:

The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets (1605): Could not resolve this reference. Could not locate the assembly "Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

我已经查看了所有导致 Nuget 包失败的原因。是因为我使用的是 Visual Studio 2015 吗? Nuget 被顶起来了吗?

有人遇到过这个问题吗?

【问题讨论】:

    标签: json.net nuget visual-studio-2015 tfsbuild


    【解决方案1】:

    根据您的 packages.config 文件中的条目仔细检查项目中的引用。

    我遇到了同样的错误,发现该项目在其引用中引用了Newtonsoft.Json 4.5.1,但是在packages.config中,条目如下:

    <package id="Newtonsoft.Json" version="5.0.8" targetFramework="net45" />
    

    将 packages.config 中的条目更改为 4.5.1 而不是 5.0.8 解决了该问题。

    <package id="Newtonsoft.Json" version="4.5.1" targetFramework="net45" />
    

    我通过检查 CI 构建服务器上的本地 _work 文件夹发现了这一点,发现它试图从中提取 .dll 的位置在该位置不可用;然后我追溯它以找出原因。 (这个问题的另一个可能原因是一个已被弃用的 NuGet 包。我也有一个引发相同错误的包。)我不确定它们是如何不同步的。这是一个最初由我继承的其他人进行的项目。

    希望,即使这不能为您解决问题,这也会帮助其他人。

    【讨论】:

      猜你喜欢
      • 2015-12-29
      • 2012-08-24
      • 1970-01-01
      • 2018-12-20
      • 2018-05-24
      • 2014-10-18
      • 2014-08-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多