为什么 msbuild 在 VS 构建正常时失败?

Why does msbuild fail while building within VS builds fine?

我们有一个复杂的解决方案(22 个子项目,其中一个是网站)无法使用 TFS Build 进行构建。如果我在构建服务器上打开解决方案,代码在 Visual Studio 内部编译得很好,但是如果我打开 CMD 提示符并尝试 MSBUILD piccsserver.sln 我会收到此错误:

"C:\TFS2017_agent\_work\s\CorePlatform\PICCS\Main\src\piccsserver.sln" 
    (default target) (1) ->
"C:\TFS2017_agent\_work\s\CorePlatform\PICCS\Main\src\PICCS_WebHost.metaproj"
 (default target) (24) ->(Build target) ->  ASPNETCOMPILER : error ASPCONFIG: Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not mat
ch the assembly reference. (Exception from HRESULT: 0x80131040) [C:\TFS2017_age
nt\_work\s\CorePlatform\PICCS\Main\src\PICCS_WebHost.metaproj]

我注意到,当我从 VS 中构建并查看网站 bin 文件夹中 NewtonSoft.Json.dll 的版本时,版本是 11.0.1,这是我所期望的,但是当我从命令构建时提示版本是4.5.11.15520.

这到底是怎么回事?从 VS 内部构建不使用 MSBUILD 吗?

我让它工作了。我将 Web.config 中的 newVersion 值从 11.0.0.0 更改为 11.0.1.0。如果仅从 command-line 构建,不知道为什么会停止,但现在它在 VS 和 command-prompt.

中构建

来自这里:

<dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-11.0.0." newVersion="11.0.0.0" />
</dependentAssembly>

对此:

<dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-11.0.0." newVersion="11.0.1.0" />
</dependentAssembly>