【问题标题】:Cannot build clean VSIX project: Tries to load Newtonsoft.Json which is not there?无法构建干净的 VSIX 项目:尝试加载不存在的 Newtonsoft.Json?
【发布时间】:2020-03-25 15:53:28
【问题描述】:

以下构建错误困扰着我。

The "CompareCommonBuildTaskVersion" task could not be loaded from the assembly C:\Users\Thijs\.nuget\packages\microsoft.vssdk.buildtools\16.6.1026\tools\VSSDK\Microsoft.VisualStudio.Sdk.BuildTasks.dll. 
Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified. 
Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.   

刚才查了一下上面提到的目录,里面有一个Newtonsoft.Json.dll,不过是12.0.2.23222(文件版本)。

我正在使用:

  • Visual Studio Enterprise 2019 预览版
    • 版本 16.6.0 预览版 1.0
  • Visual Studio 企业版 2019
    • 版本 16.5.0

阅读 EricEJ 发布的链接后,我检查了我的 devenv.exe.config,其中包含以下(正确)AssemblyRedirect:

    <dependentAssembly>
      <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
      <bindingRedirect oldVersion="4.5.0.0-12.0.0.0" newVersion="12.0.0.2"/>
      <codeBase version="12.0.0.2" href="PrivateAssemblies\Newtonsoft.Json.12.0.0.2\Newtonsoft.Json.dll"/>
    </dependentAssembly>

问题似乎出在实际的 BuildTools 包上(请参阅答案)。

【问题讨论】:

  • @ErikEJ 这很有启发性,我以前没有读过。它确实谈到了“当你想使用 Newtonsoft.Json 时”,这不是我想要的。据我所知,devenv.exe.config 绑定重定向可能是错误的不知何故。我会检查的。
  • @PerryQian-MSFT 我在等待某人(可能是我)也能够解释“为什么”。由于投资回报率很低,我会接受我目前的答案。

标签: c# visual-studio-2019 visual-studio-extensions vsix


【解决方案1】:

我再次尝试了不同的 BuildTools 包版本,从最新开始,安装后,重新启动 VS,然后重新构建解决方案:

  • 版本 16.6.1026 -> 3 月 -> 不工作
  • 版本 16.6.1024 -> 3 月 -> 不工作
  • 版本 16.5.2044 - 2 月 -> 工作中

到目前为止,降级似乎解决了我的问题。

【讨论】:

  • 当您在 VS 2019 16.6 预览版 1 中创建项目时,它会添加版本为 16.6.3 的 BuildTools 包(NuGet.org 上没有)。我现在正在使用那个版本。
猜你喜欢
  • 1970-01-01
  • 2018-07-05
  • 2011-12-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多