为什么在 VS 构建正常的情况下构建 msbuild 会失败?



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

"C:TFS2017_agent_work4sCorePlatformPICCSMainsrcpiccsserver.sln" 
(default target) (1) ->
"C:TFS2017_agent_work4sCorePlatformPICCSMainsrcPICCS_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_work4sCorePlatformPICCSMainsrcPICCS_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。不知道为什么如果仅从命令行构建会停止构建,但现在它同时在 VS 和命令提示符下构建。

由此:

<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>

相关内容

最新更新