当我清理并构建具有多个项目的解决方案时,输出窗口将报告构建成功。然而,当我查看错误列表窗口时,它向我显示了这样的警告:

发现同一依赖程序集的不同版本之间存在无法解决的冲突。当日志详细信息设置为detailed时,这些引用冲突将在生成日志中列出。C:\Program Files (x86)\MSBuild\12.0\bin\ Microsoft.Common.CurrentVersion.targets

当我双击此消息时,它将打开C:\Program Files (x86)\MSBuild\12.0\bin\ Microsoft.Common.CurrentVersion。目标文件,但我不明白任何东西在它。

我正在使用Visual Studio Express 2013的Web。

我如何找出什么是错误的,与哪个DLL,然后我如何使警告消失?


当前回答

根据其他答案,将输出日志记录级别设置为detailed并在那里搜索冲突,这将告诉您下一步要查看的位置。

在我的例子中,它让我在几个方向上寻找引用的源,但最后发现问题出在我的一个可移植类库项目上,它瞄准了错误的版本,并引入了自己的引用版本,因此产生了冲突。一个快速的重新定位,问题就解决了。

其他回答

I found that, sometimes, nuget packages will install (what I'm guessing are) .NET Core required components or other items that conflict with the already-installed framework. My solution there was to open the project (.csproj) file and remove those references. For example, System.IO, System.Threading and such, tend to be added when Microsoft.Bcl is included via some recently installed NuGet package. There's no reason for specific versions of those in my projects, so I remove the references and the project builds. Hope that helps.

您可以在项目文件中搜索“参考”并删除冲突。如果它们包含在系统中,那么去掉它们,构建应该可以工作。这可能不能回答这个问题的所有情况-我确保你知道什么对我有用:)

我注释掉的例子:

< !<参考Include=“系统。”Runtime,版本=2.6.9.0,Culture=neutral, PublicKeyToken= b03f5f7f3a, processorArchitecture=MSIL"> -> < !- <HintPath>$(解决方案)packages\Microsoft.Bcl.1.1.9\lib\net40\系统. runtpath > < !<Private>True</Private> -> < !</参考> ->

根据其他答案,将输出日志记录级别设置为detailed并在那里搜索冲突,这将告诉您下一步要查看的位置。

在我的例子中,它让我在几个方向上寻找引用的源,但最后发现问题出在我的一个可移植类库项目上,它瞄准了错误的版本,并引入了自己的引用版本,因此产生了冲突。一个快速的重新定位,问题就解决了。

显然有很多不同的原因,因此有很多解决这个问题的方法。为了将我的程序集加入到混合中,我们将之前在我们的Web项目中直接引用的程序集(System.Net.Http)升级到由NuGet管理的版本。这删除了该项目中的直接引用,但是我们的测试项目仍然包含直接引用。升级两个项目以使用nuget管理的程序集解决了这个问题。

在将包从nuget切换到本地引用dll后,我遇到了这个问题。这个问题是app.config中的旧的运行时绑定。

我只能通过对比所显示的两条消息来进一步支持Ruben的回答:

信息是:

C:\Program Files (x86)\MSBuild\12.0\bin\ Microsoft.Common.CurrentVersion.targets(1697,5):警告MSB3277:发现同一依赖程序集的不同版本之间存在无法解决的冲突。当日志详细信息设置为detailed时,这些引用冲突将在生成日志中列出。

So, Ruben's right—this is just not true. There are no conflicts whatsoever, just a missing assembly. This is especially boring when the project is an ASP.NET application, since the views are compiled on demand, that is, just before displayed for the first time. This is when it becomes necessary to have the assembly available. (There's an option to pre-compile the views together with the rest of the code, but this is another story.) On the other hand, if you set the verbosity to Diagnostic you get the following output:

C:\Program Files (x86)\MSBuild\12.0\bin\ Microsoft.Common.CurrentVersion.targets(1697,5):警告MSB3245:无法解析此引用。无法定位程序集“System.Web”。Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"。检查以确保程序集存在于磁盘上。如果您的代码需要此引用,则可能会出现编译错误。

因此,你所需要做的就是:

手动向程序集添加引用(可能将其定位到磁盘上) GAC,并将其添加为“直接”参考),或 使用NuGet包(如果在图库中发布)下载它并引用其中包含的程序集。

更多关于NuGet画廊在这里。 更多关于预编译ASP。NET视图。