Why does msbuild fail while building within VS builds fine?

孤者浪人 提交于 2019-12-24 07:04:10

问题


We have a complex solution (22 sub-projects, one of which is a website) that won't build using TFS Build. If I open the solution on the build server the code compiles fine inside of Visual Studio, but if I open a CMD prompt and try MSBUILD piccsserver.sln I get this error:

"C:\TFS2017_agent\_work\4\s\CorePlatform\PICCS\Main\src\piccsserver.sln" 
    (default target) (1) ->
"C:\TFS2017_agent\_work\4\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\4\s\CorePlatform\PICCS\Main\src\PICCS_WebHost.metaproj]

I notice that when I build from within VS and look at the version of NewtonSoft.Json.dll in the website's bin folder, the version is 11.0.1 which is what I expect, but when I build from the command prompt the version is 4.5.11.15520.

What the heck is going on here? Doesn't building from within VS use MSBUILD?


回答1:


I got it to work. I changed the value of newVersion in the Web.config from 11.0.0.0 to 11.0.1.0. No idea why that stops if from building only from the command-line, but now it builds both in VS and at the command-prompt.

From this:

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

to this:

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


来源:https://stackoverflow.com/questions/49456605/why-does-msbuild-fail-while-building-within-vs-builds-fine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!