aspnet_compiler.exe 在全局别名中找到多种类型,但我不能!
今天继承一个新项目,试图让数百个警告消失,结果难倒了这个。 ASP.NET MVC 2,框架 4.0 项目在 VS2010 中编译得很好,但是当构建过程交给 aspnet_compiler.exe 时,我得到以下内容(从输出窗口剪切并粘贴)
AfterBuild:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v temp -p C:\data\crecare\CreCare20110403\CreCare.Mvc\\..\CreCare.Mvc
ASPNETCOMPILER : warning CS1685: The predefined type 'System.Runtime.CompilerServices.ExtensionAttribute' is defined in multiple assemblies in the global alias; using definition from 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll'
:对项目中的引用进行繁琐的逐个程序集审查不会出现任何多重定义。据我所知,以前的团队没有尝试在以前的 ASP.NET 版本中构建任何扩展(造成此错误的一个原因,我已了解到 );我认为这从一开始就以4.0为目标。
这只是一个警告,我想我可以忽略它(你甚至不能使用 aspnet_compiler.exe /nowarn,所以我必须看看它们)——但这让我很恼火。关于如何追查这个问题有什么建议吗?项目路径中的“\..\”应该让我担心吗?我运行的是 64 位 Windows;它不是同时查看 x86 和 64 吗?
值得注意的是,解决方案中使用VS2010中的对象浏览器只能查找aspnet_compiler.exe找到的程序集中的类型;对该类型的搜索仅给出一个结果。 aspnet_compiler.exe 是否查找 VS2010 没有查找的地方?
Inheriting a new project today, trying to make hundreds of warnings go away, and stumped on this. ASP.NET MVC 2, framework 4.0 project which compiles just fine in VS2010, but when the build process hands off to aspnet_compiler.exe, I get the following (cut and pasted from the Output window):
AfterBuild:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v temp -p C:\data\crecare\CreCare20110403\CreCare.Mvc\\..\CreCare.Mvc
ASPNETCOMPILER : warning CS1685: The predefined type 'System.Runtime.CompilerServices.ExtensionAttribute' is defined in multiple assemblies in the global alias; using definition from 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll'
Both a search in the Object Browser and a tedious assembly-by-assembly review of the references in the project do not turn up any multiple definition. As far as I can tell the previous team did not try to build any extensions in previous ASP.NET versions (one cause of this error, I have learned ); I think this has targeted 4.0 from the start.
It's only a warning and I suppose I can ignore it (you can't even /nowarn with aspnet_compiler.exe, so I have to look at them) -- but it rubs me wrong. Any suggestions for how to hunt this down? Should that "\..\" in the path to the project worry me? I'm running 64-bit windows; it's not looking at the x86 and 64 at the same time?
It's worth noting that the using the Object Browser in VS2010 in the solution only finds the type in the assembly that aspnet_compiler.exe finds; a search for the type only gives one result. Is aspnet_compiler.exe looking in places that VS2010 doesn't?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就像你说的,这是 Mono.Cecil 的功劳。
如果您确实引用了 Mono.Cecil.Dll 并实现了扩展方法,则此警告可能会变成错误,因为执行此操作时,编译器会优先考虑 Mono.Cecil 实现。
我不明白为什么应该用于 .net 4 的 db4o 程序集没有考虑到这一点,但我们可以确认这一点,因为我们已经研究了同一问题。
只要您仅复制以输出 Mono.Cecil(我们添加为链接并将其设置为复制到输出)而不是使用普通引用,一切都可以正常工作。这个警告很烦人,但考虑到 db4o 上这些程序集的奇怪情况,我们宁愿暂时不处理构建其源代码。
Just like you said this is due to Mono.Cecil.
This warning can become an error if you do have a reference to Mono.Cecil.Dll and implement extension methods / because when doing the compiler gives precedence to the Mono.Cecil implementation.
I don't get why db4o assemblies that are supposed to be for .net 4 are not taking this into account, but we can confirm the same as we've looked into the same issue.
As long as you only copy to output the Mono.Cecil (we add as a link and set it to copy to output) instead of using a normal reference, all works fine. The warning is annoying, but given the weird situation around these assemblies on db4o, we preferred not dealing with building its source for now.