MSBuild 和 <AutoUnifyAssemblyReferences />

MSBuild and <AutoUnifyAssemblyReferences />

"Microsoft.Bcl.Build.targets" 包含此块:

    <!-- 
  Workaround MSBuild issue that prevents System.Runtime 2.5 and System.Threading.Tasks 2.5 from
  satisfying indirect dependencies on System.Runtime 1.5 and System.Threading.Tasks 1.5 respectively.  
-->
<AutoUnifyAssemblyReferences>false</AutoUnifyAssemblyReferences>

"AutoUnifyAssemblyReferences"实际上是做什么的?

它直接映射到 ResolveAssemblyReferencs-TaskAutoUnify 参数。

文档摘录:

This parameter is used for building assemblies, such as DLLs, which cannot have a normal App.Config file.

When true, the resulting dependency graph is automatically treated as if there were anApp.Config file passed in to the AppConfigFile parameter.This virtual App.Config file has a bindingRedirect entry for each conflicting set of assemblies such that the highest version assembly is chosen.A consequence of this is that there will never be a warning about conflicting assemblies because every conflict will have been resolved.

When true, each distinct remapping will result in a high priority comment showing the old and new versions and that AutoUnify was true.

When true, the AppConfigFile parameter must be empty

When false, no assembly version remapping will occur automatically.When two versions of an assembly are present, a warning is issued.

When false, each distinct conflict between different versions of the same assembly results in a high-priority comment.These comments are followed by a single warning.The warning has a unique error code and contains text that reads "Found conflicts between different versions of reference and dependent assemblies".

突出显示的句子似乎解释了您所指的 Microsoft.Bcl.Build.Targets 中的评论。

(这个参数也影响不常见的MSB3247 warning。)

因此,AutoUnifyAssemblyReferences 的默认值对于某些类型的 "exe" 程序集设置为 false,对于其他程序集类型设置为 true(参见 %Windir%\Microsoft.NET\Framework64\v4.0*\Microsoft.Common.Targets 了解详情)。