MSBuild CoreCompile 目标如何识别参考程序集
任何人都可以阐明 TFS2010 (RC) Microsoft.TeamFoundation.Build 目标中的 CoreCompile 任务如何生成传递给 csc.exe 的程序集引用吗?
我们看到对 System.Xml.dll 版本 2.0 和 4.0 的引用(下面以粗体显示),但是我们在项目程序集引用上使用“特定版本:true”标志并且 btproj 文件中没有对 4.0 程序集的引用:
C:\Windows\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /platform:x86 /errorreport:prompt /warn:4 /define:TRACE
/reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Configuration.dll
/reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll
**/reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll**
/reference:C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.dll
**/reference:C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Xml.dll**
/reference:C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Data.dll
/reference:C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Web.Services.dll
更新:我已经检查了 ResolveAssemblyReferences 目标的输出(来自 Microsoft.Common.targets >) 并且可以看到项目列表中仅包含项目中引用的程序集(即 2.0 框架程序集)'_ResolveAssemblyReferenceResolvedFiles':
ResolveAssemblyReferenceResolvedFiles:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Configuration.dll;
C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll;
C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll
但是,CoreCompile 目标仍然包含如上所述的 4.0 程序集。
更新 2:好的,我已将此问题追溯到 BizTalk 构建脚本中的 AddBizTalkHiddenReferences 目标中的一个不起眼的错误。此特定目标尝试添加其他程序集,包括上面重复的程序集。
但是,它使用“mscoree.dll”中的 GetCORSystemDirectory 返回加载到进程中的公共语言运行时 (CLR) 的安装目录,在本例中是加载到 MSBuild 中的 4.0 框架;因此,助手认为它没有引用 System.Xml 程序集并添加它,因此出现重复。
Can anyone shed any light on how the CoreCompile task in TFS2010 (RC) Microsoft.TeamFoundation.Build targets generates the assembly references that are passed to csc.exe?
We are seeing references to both version 2.0 and 4.0 of System.Xml.dll (shown in bold below), however we are using the 'Specific Version: true' flag on the project assembly reference and there are no references to the 4.0 assembly in the btproj file:
C:\Windows\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /platform:x86 /errorreport:prompt /warn:4 /define:TRACE
/reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Configuration.dll
/reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll
**/reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll**
/reference:C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.dll
**/reference:C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Xml.dll**
/reference:C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Data.dll
/reference:C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Web.Services.dll
Update: I've checked the output of the ResolveAssemblyReferences target (from Microsoft.Common.targets) and can see that only the assemblies referenced in the project (i.e. the 2.0 framework assemblies) are included in the item list '_ResolveAssemblyReferenceResolvedFiles':
ResolveAssemblyReferenceResolvedFiles:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Configuration.dll;
C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll;
C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll
However, the CoreCompile target still includes the 4.0 assemblies as detailed above.
Update 2: Ok, I've tracked this down to an obscure bug in the AddBizTalkHiddenReferences target in the BizTalk build scripts. This particular target attempts to add additional assemblies, including the ones that are duplicated above.
However, it uses the GetCORSystemDirectory from 'mscoree.dll' which returns the installation directory of the common language runtime (CLR) that is loaded into the process, in this case the 4.0 framework loaded into MSBuild; as a result, the helper doesn't think it has the System.Xml assembly referenced and adds it, hence the duplicate.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
引用程序集由文件
Windows\Microsoft.NET\Framework\$(Version)\Microsoft.Common.targets
中的ResolveAssemblyReferences
目标基于Reference< /code> 项目文件中定义的项目。
Reference assemblies are resolved by
ResolveAssemblyReferences
target in the fileWindows\Microsoft.NET\Framework\$(Version)\Microsoft.Common.targets
based on theReference
items defined in your project file.