简体   繁体   English

MSBuild maxcpucount> 1导致生成错误

[英]MSBuild maxcpucount > 1 Causes build errors

I'm trying to build about 600 projects some are .net 2.0, some are 3.5. 我正在尝试构建大约600个项目,有些是.net 2.0,有些是3.5。 I'm using Windows 2003 Enterprise Edition 32 bit with all the latest windows updates. 我正在使用Windows 2003企业版32位与所有最新的Windows更新。

Builds fine when maxcpucount is 1. If I bump it up to try and improve performance it get reference errors. 当maxcpucount为1时构建正常。如果我试图提高性能,则会出现引用错误。 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. 我没有在解决方案文件上使用msbuild。 I'm using wildcards to select all csproj files then feeding them to msbuild. 我正在使用通配符选择所有csproj文件,然后将它们提供给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 95%是项目引用,唯一的二进制引用是核心实用程序库

In order for MSBuild to run with multiple cores/cpus, it needs to be able to determine beforehand what all of the dependencies are. 为了使MSBuild能够运行多个内核/ cpus,它需要能够事先确定所有依赖项是什么。 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. 我还没有找到一个用GUI检查这个的好方法,所以你可能必须卸载并编辑一个不在multicpu中构建的项目文件来查看xml。

A project reference should look like: 项目参考应如下所示:


<ProjectReference Include="..\..\Manager\Manager.csproj">
      <Project>{C0F60D74-3EF9-4B49-9563-66E70D0DDF43}</Project>
      <Name>Manager</Name>
</ProjectReference>

and a filepath reference would look like: 和文件路径引用如下所示:


<Reference Include="Manager.dll, Version=2.0.0.0, Culture=neutral, PublicKeyToken=e79aa50eb4f67b0c, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>....\Manager\Manager.dll</HintPath>
</Reference>

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 请看这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM