MSBuild maxcpucount > 1 导致构建错误
我正在尝试构建大约 600 个项目,其中一些是 .net 2.0,一些是 3.5。 我使用的是 Windows 2003 Enterprise Edition 32 位以及所有最新的 Windows 更新。
当 maxcpucount 为 1 时构建良好。如果我将其提高以尝试提高性能,则会出现引用错误。 当我查看发生错误的项目引用时,它们似乎应该按顺序构建。
下面我提供了导致构建被破坏的错误的示例。 不要纠结于项目名称或相对路径,因为我已经更改了它,这样我就不会给我的雇主带来麻烦。
这就像当超过一个核心正在构建解决方案时无法正确解析相关项目引用。
"C:\SVN\MyLibrary\MyLibrary.csproj" (default target) (15) ->
"C:\SVN\FileProcessor\FileProcessor.csproj" (default target) (17) ->
(ResolveProjectReferences target) ->
C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets : warning : The referenced project '..\..\Manager\Manager.csproj' does not exist.
"C:\SVN\MyLibrary\MyLibrary.csproj" (default target) (15) ->
"C:\SVN\FileProcessor\FileProcessor.csproj" (default target) (17) ->
(CoreCompile target) ->
FileProcessor.cs(18,39): error CS0234: The type or namespace name 'Manager' does not exist in the namespace 'TheNamespace' (are you missing an assembly reference?)
我没有在解决方案文件上使用 msbuild。 我使用通配符选择所有 csproj 文件,然后将它们提供给 msbuild。 对于开发,我们有多种解决方案用于系统的不同组件。 95% 是项目参考,唯一的二进制参考是核心实用程序库
I'm trying to build about 600 projects some are .net 2.0, some are 3.5. I'm using Windows 2003 Enterprise Edition 32 bit with all the latest windows updates.
Builds fine when maxcpucount is 1. If I bump it up to try and improve performance it get reference errors. When I look at the project references from where the error occurred it appears they should have been built in order.
Below I've provided an example of the errors that are causing the build to be broken. Don't get hung up on the project names or the relative paths because I've changed this so I don't get in trouble with my employer.
It's like the relative project references can't be properly resolved when more then one core is building the solution.
"C:\SVN\MyLibrary\MyLibrary.csproj" (default target) (15) ->
"C:\SVN\FileProcessor\FileProcessor.csproj" (default target) (17) ->
(ResolveProjectReferences target) ->
C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets : warning : The referenced project '..\..\Manager\Manager.csproj' does not exist.
"C:\SVN\MyLibrary\MyLibrary.csproj" (default target) (15) ->
"C:\SVN\FileProcessor\FileProcessor.csproj" (default target) (17) ->
(CoreCompile target) ->
FileProcessor.cs(18,39): error CS0234: The type or namespace name 'Manager' does not exist in the namespace 'TheNamespace' (are you missing an assembly reference?)
I'm not using msbuild on a solution file. I'm using wildcards to select all csproj files then feeding them to msbuild. For development we have multiple solutions we use for different components of the system. 95% are project reference, the only binary references are for core utility libs
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了让 MSBuild 在多个核心/CPU 上运行,它需要能够事先确定所有依赖项是什么。 一般来说,这意味着您需要将所有项目放在一个巨大的解决方案中,并将所有引用设置为项目引用,或者设置多个解决方案并将它们设置为按正确的顺序构建。
听起来您现在正在运行单一解决方案版本,因此您需要确保对其他项目的所有引用都正确设置为项目引用,而不是文件路径引用。
我还没有找到使用 GUI 检查这一点的好方法,因此您可能必须卸载并编辑未在多 CPU 中构建的项目文件之一才能查看 xml。
项目引用应如下所示:
文件路径引用应如下所示:
看起来您至少有一些参考设置正确,因为您收到的错误消息至少有一个对另一个项目的调用,所以您不需要更新所有内容,只需检查为您提供的一对问题。
In order for MSBuild to run with multiple cores/cpus, it needs to be able to determine beforehand what all of the dependencies are. Generally this means you either need to have all of your projects in a single huge solution and set up all of your references to be project references or set up multiple solutions and set them to build in the correct order.
It sounds like you're running the single solution version right now, so you'll want to make sure all of your references to your other projects are set up correctly as project references, not filepath references.
I haven't found a good way to check this with the GUI, so you'll probably have to unload and edit one of the project files that isn't building in multicpu to take a look at the xml.
A project reference should look like:
and a filepath reference would look like:
It looks like you have at least some of your references set up correctly, since the error message you have has at least one call out to another project, so you shouldn't need to update everything, just check on the couple that are giving you problems.
我可能会迟到,你可能已经解决了这个问题。 但我遇到了同样的错误,发现这是由于我的一个项目的路径长度太大所致。
请参阅此处
I could be quite late and you might have solved this problem. But I was stuck with the same error and found that it was due to the path length of one of my projects being too large.
Please see here