解决MSB3247 - 不同版本的同一依赖程序集之间发现冲突冲突、不同、版本、发现

2023-09-02 10:19:48 作者:卖萌是一种精神

一个.NET 3.5解决方案的MSBuild编译时结束了这一警告。

A .NET 3.5 solution ended up with this warning when compiling with msbuild.

有时候NDepend的可能助阵,但在这种情况下,它没有给出进一步的细节。 像鲍勃我最后不得不诉诸ILDASM打开每个组件,直到我发现了一个被引用的依赖程序集的旧版本。

Sometimes NDepend might help out but in this case it didn't give any further details. Like Bob I ended up having to resort to opening each assembly in ILDASM until I found the one that was referencing an older version of the dependant assembly.

我也尝试使用MSBUILD从VS 2010 Beta 2中(作为连接文章指出这是固定在CLR的下一个版本),但没有提供任何更详细的是(也许固定后测试版2)

I did try using MSBUILD from VS 2010 Beta 2 (as the Connect article indicated this was fixed in the next version of the CLR) but that didn't provide any more detail either (maybe fixed post Beta 2)

有没有更好的(更自动化)的方法呢?

Is there a better (more automated) approach?

推荐答案

将MSBuild项目生成输出的详细程度为详细或更高。为此,请按照下列步骤操作:

Change the "MSBuild project build output verbosity" to "Detailed" or above. To do this, follow these steps:

打开选项对话框。(工具 - >选项... ) 在左边的树中,选择项目和解决方案节点,然后选择生成和运行。 注意:如果此节点没有显示出来,请确保在对话框底部的复选框显示被选中,所有设置 Bring up the Options dialog (Tools -> Options...). In the left-hand tree, select the Projects and Solutions node, and then select Build and Run. Note: if this node doesn't show up, make sure that the checkbox at the bottom of the dialog Show all settings is checked.

在弹出的工具/选项页,将 MSBuild项目生成输出的详细程度水平取决于您的版本相应的设置:

In the tools/options page that appears, set the MSBuild project build output verbosity level to the appropriate setting depending on your version:

诊断在VS2012,VS2013或VS2015(在这些版本的消息时的说的你应该使用详细,的但是这是完全错误的,你应该使用诊断) 详细当你在VS2010 正常就足够在VS2008或以上。 Diagnostics when on VS2012, VS2013 or VS2015 (the message in these versions says you should use "Detailed", but this is plain wrong, you should use "Diagnostics") Detailed when you're on VS2010 Normal will suffice in VS2008 or older.

退房的MSBuild的消息。该 ResolveAssemblyReferences 的任务,它是从哪个MSB3247起源任务,应该可以帮助您调试这个特殊的问题。

Check out the MSBuild messages. The ResolveAssemblyReferences task, which is the task from which MSB3247 originates, should help you debug this particular issue.

我的具体情况是不正确的引用SqlServerCe。见下文。我有两个项目引用两个不同版本SqlServerCe的。我去项目与旧版本,删除了引用,那么添加正确的引用。

My specific case was an incorrect reference to SqlServerCe. See below. I had two projects referencing two different versions of SqlServerCe. I went to the project with the older version, removed the reference, then added the correct reference.

Target ResolveAssemblyReferences:
    Consider app.config remapping of assembly "System.Data.SqlServerCe, ..." 
        from Version "3.5.1.0" [H:...DebugSystem.Data.SqlServerCe.dll] 
        to Version "9.0.242.0" [C:Program FilesMicrosoft Visual Studio 8Common7IDEPublicAssembliesSystem.Data.SqlServerCe.dll]
        to solve conflict and get rid of warning.
    C:WINDOWSMicrosoft.NETFrameworkv3.5Microsoft.Common.targets : 
        warning MSB3247: Found conflicts between different versions of the same dependent assembly.

您不必打开每个组件,以确定引用的程序集的版本。

You do not have to open each assembly to determine the versions of referenced assemblies.

您可以检查每个引用的属性。 打开项目属性,并检查参考文献部分的版本。 在一个文本编辑器打开的项目。 使用.net反射。