MSBuild maxcpucount > 1 导致构建错误

发布于 2024-07-11 08:25:07 字数 1152 浏览 11 评论 0原文

我正在尝试构建大约 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

终弃我 2024-07-18 08:25:07

为了让 MSBuild 在多个核心/CPU 上运行,它需要能够事先确定所有依赖项是什么。 一般来说,这意味着您需要将所有项目放在一个巨大的解决方案中,并将所有引用设置为项目引用,或者设置多个解决方案并将它们设置为按正确的顺序构建。

听起来您现在正在运行单一解决方案版本,因此您需要确保对其他项目的所有引用都正确设置为项目引用,而不是文件路径引用。

我还没有找到使用 GUI 检查这一点的好方法,因此您可能必须卸载并编辑未在多 CPU 中构建的项目文件之一才能查看 xml。

项目引用应如下所示:


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

文件路径引用应如下所示:


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

看起来您至少有一些参考设置正确,因为您收到的错误消息至少有一个对另一个项目的调用,所以您不需要更新所有内容,只需检查为您提供的一对问题。

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:


<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.

行至春深 2024-07-18 08:25:07

我可能会迟到,你可能已经解决了这个问题。 但我遇到了同样的错误,发现这是由于我的一个项目的路径长度太大所致。
请参阅此处

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文