简体   繁体   English

如何控制 Batch Build → Build All 的顺序

[英]How to control order of Batch Build → Build All

I have a C++ solution with 4 projects and 24 configurations.我有一个包含 4 个项目和 24 个配置的 C++ 解决方案。 The projects are cryptest , cryptlib , cryptdll and dlltest .该项目是cryptestcryptlibcryptdlldlltest And then there's a partial cross product of x86, x64, debug, release, DLL export, and DLL import.然后是 x86、x64、调试、发布、DLL 导出和 DLL 导入的部分交叉产品。

There's a not-so-apparent dependency that I can't seem to express under the UI or by modifying the project files by hand.有一个不太明显的依赖项,我似乎无法在 UI 下或通过手动修改项目文件来表达。 The dependency is all the DLL related projects depend upon cryptest, Release Win32 .依赖项是所有与 DLL 相关的项目都依赖于cryptest, Release Win32

Visual Studio allows us to build all configurations by selecting the Build menu, and then Batch Build... → Select All → Build . Visual Studio 允许我们通过选择Build菜单来构建所有配置,然后Batch Build... → Select All → Build When I perform a Build All , the first configuration built is:当我执行Build All 时构建的第一个配置是:

------ Build started: Project: cryptlib, Configuration: DLL-Import Debug x64 ------
Performing Custom Build Step
 Assembling: c:\Documents and Settings\cryptopp-5.6.3\x64masm.asm
Performing Custom Build Step
Compiling...
pch.cpp
...

As can be seen above, the machinery chooses cryptlib, DLL-Import Debug x64 as its first choice.从上面可以看出,机器选择了cryptlib, DLL-Import Debug x64作为其首选。 I want the following order:我想要以下顺序:

  • cryptlib, Release Win32
  • cryptest, Release Win32
  • Don't care about remaining 22....不在乎剩下的22....

The problem is I cannot tell Visual studio that all Win32 and x64 DLL projects depend upon the Win32 cryptest .问题是我无法告诉 Visual Studio所有Win32 和 x64 DLL 项目都依赖于 Win32 cryptest

How can I control the order of Batch Build → Build All ?如何控制Batch Build → Build All的顺序?


Currently I have to run through Build All twice.目前我必须运行Build All两次。 The first ends with:第一个结尾:

========== Build: 20 succeeded, 4 failed, 0 up-to-date, 0 skipped ==========

The second run ends with:第二次运行以:

========== Build: 4 succeeded, 0 failed, 20 up-to-date, 0 skipped ==========

When reordering the solution file's GlobalSection(ProjectConfigurationPlatforms) with a text editor (and placing them in the exact order I want), these are the kind of warm and fuzzy results I encounter.当使用文本编辑器重新排序解决方案文件的GlobalSection(ProjectConfigurationPlatforms)时(并按照我想要的确切顺序放置它们),这些是我遇到的那种温暖和模糊的结果。 The 24 configurations will build with Build All under Visual Studio 2005, but Build All does nothing (literally, nothing) under Visual Studio 2008 after testing an upgrade.这 24 种配置将在 Visual Studio 2005 下使用Build All构建,但在测试升级后, Build All在 Visual Studio 2008 下什么也不做(字面意思是什么都不做)。

And when I manually try to build a project (right click project, then Build ), I get a result like:当我手动尝试构建项目(右键单击项目,然后单击Build )时,我得到如下结果:

1>------ Skipped Build: Project: cryptlib ------
1> 
2>------ Skipped Build: Project: cryptest ------
2> 

With no reasons or explanations.没有理由或解释。 It sure would be nice if Visual Studio provided a log file in an attempt to decipher the behavior.如果Visual Studio 提供一个日志文件来尝试破译行为,那肯定会很好。


A related issue is Visual Studio selects << some project >> as the default Startup project with no declarative way to change it .一个相关的问题是 Visual Studio 选择<< some project >>作为默认启动项目,但没有声明性的方式来更改它 That means a particular project needs to be the first one listed in the solution file, and that cannot change.这意味着特定项目需要是解决方案文件中列出的第一个项目,并且不能更改。


I'm having a hard time finding a solution that is amicable to both Visual Studio 2005 (how the source files are distributed) and a post-Visual Studio 2010 upgrade (how some folks use it).我很难找到适合 Visual Studio 2005(源文件的分发方式)和 Visual Studio 2010 后升级(某些人如何使用它)的解决方案。

I can kind of find some information on the subject, like Project settings changes with VS2010 from a blog.我可以从博客中找到有关该主题的一些信息,例如VS2010 的项目设置更改 But its not really clear how to effect a dependency change as described above, and the blog only applies to VS2010 or above.但是上面描述的依赖改变如何实现并不是很清楚,而且博客只适用于VS2010或更高版本。

Create a x86 and x64 project for cryptest and cryptlib.为 cryptest 和 cryptlib 创建一个 x86 和 x64 项目。

For each x86/x64 project pair, use Add As Link to link to all the files in the other project so you only have just one copy of each file.对于每个 x86/x64 项目对,使用Add As Link链接到另一个项目中的所有文件,这样每个文件只有一个副本。

...links shown with the red arrows... ...用红色箭头显示的链接...

解决方案

Configuration Manager配置管理器

Use Configuration Manager to build x86 only for the x86 projects, and x64 only for the x64 projects.使用 Configuration Manager 仅为 x86 项目构建 x86,仅为 x64 项目构建 x64。

Also use the dropdown for each Platform and remove the extra platform that does not apply to the corresponding project.同时使用每个平台的下拉菜单并删除不适用于相应项目的额外平台。

Also ensure that for x86 builds you are not building x64 targets, and for x64 builds you are not building x86 targets by unchecking the appropriate Build checkbox.还要确保对于 x86 构建,您不是在构建 x64 目标,对于 x64 构建,您不是通过取消选中相应的构建复选框来构建 x86 目标。

配置管理器

Dependencies依赖关系

Create dependencies as such:像这样创建依赖项:

  • cryptlib32 depends on nothing cryptlib32 不依赖任何东西
  • cryptest32 depends on cryptlib32 cryptest32 依赖于 cryptlib32
  • cryptlib64 depends on cryptlib32 and cryptest32 cryptlib64 依赖于 cryptlib32 和 cryptest32
  • cryptest64 depends on cryptlib64 cryptest64 依赖于 cryptlib64
  • all your remaining projects depend on cryptlib32/64 and cryptest32/64 as appropriate所有剩余的项目都取决于 cryptlib32/64 和 cryptest32/64

...one example... ……一个例子……

项目依赖

Result结果

This should produce the results you want.这应该会产生您想要的结果。

Testing测试

In my test project, this worked as expected.在我的测试项目中,这按预期工作。 I named all my code with the prefix ClassLibraries , and just added lib and test on the end to mimic your config, and final is just any project after the first two projects...我用前缀ClassLibraries命名了我的所有代码,并在最后添加了libtest来模仿您的配置,而final只是前两个项目之后的任何项目......

The x86 lib and test build first, x64 lib and test next, and all the other stuff follows...首先是 x86 库和测试构建,然后是 x64 库和测试,然后是所有其他东西......

------ Rebuild All started: Project: ClassLibraryLib32, Configuration: Debug x86 ------
  ClassLibraryLib32 -> C:\Users\Kory\Source\KoryG-Code\Solution1\ClassLibraryLib32\bin\x86\Debug\ClassLibraryLib.dll
------ Rebuild All started: Project: ClassLibraryLib32, Configuration: Release x86 ------
  ClassLibraryLib32 -> C:\Users\Kory\Source\KoryG-Code\Solution1\ClassLibraryLib32\bin\x86\Release\ClassLibraryLib.dll
------ Rebuild All started: Project: ClassLibraryTest32, Configuration: Release x86 ------
  ClassLibraryTest32 -> c:\users\kory\Source\KoryG-Code\Solution1\ClassLibraryTest32\bin\x86\Release\ClassLibraryTest.dll
------ Rebuild All started: Project: ClassLibraryTest32, Configuration: Debug x86 ------
  ClassLibraryTest32 -> c:\users\kory\Source\KoryG-Code\Solution1\ClassLibraryTest32\bin\x86\Debug\ClassLibraryTest.dll
------ Rebuild All started: Project: ClassLibraryLib64, Configuration: Debug x64 ------
  ClassLibraryLib64 -> C:\Users\Kory\Source\KoryG-Code\Solution1\ClassLibraryLib64\bin\x64\Debug\ClassLibraryLib.dll
------ Rebuild All started: Project: ClassLibraryLib64, Configuration: Release x64 ------
  ClassLibraryLib64 -> C:\Users\Kory\Source\KoryG-Code\Solution1\ClassLibraryLib64\bin\x64\Release\ClassLibraryLib.dll
------ Rebuild All started: Project: ClassLibraryTest64, Configuration: Release x64 ------
  ClassLibraryTest64 -> c:\users\kory\Source\KoryG-Code\Solution1\ClassLibraryTest64\bin\x64\Release\ClassLibraryTest.dll
------ Rebuild All started: Project: ClassLibraryTest64, Configuration: Debug x64 ------
  ClassLibraryTest64 -> c:\users\kory\Source\KoryG-Code\Solution1\ClassLibraryTest64\bin\x64\Debug\ClassLibraryTest.dll
------ Rebuild All started: Project: ClassLibraryFinal, Configuration: Release x86 ------
  ClassLibraryFinal -> c:\users\kory\Source\KoryG-Code\Solution1\ClassLibraryFinal\bin\x86\Release\ClassLibraryFinal.dll
------ Rebuild All started: Project: ClassLibraryFinal, Configuration: Release x64 ------
  ClassLibraryFinal -> c:\users\kory\Source\KoryG-Code\Solution1\ClassLibraryFinal\bin\x64\Release\ClassLibraryFinal.dll
------ Rebuild All started: Project: ClassLibraryFinal, Configuration: Debug x86 ------
  ClassLibraryFinal -> c:\users\kory\Source\KoryG-Code\Solution1\ClassLibraryFinal\bin\x86\Debug\ClassLibraryFinal.dll
------ Rebuild All started: Project: ClassLibraryFinal, Configuration: Debug x64 ------
  ClassLibraryFinal -> c:\users\kory\Source\KoryG-Code\Solution1\ClassLibraryFinal\bin\x64\Debug\ClassLibraryFinal.dll
========== Rebuild All: 12 succeeded, 0 failed, 0 skipped ==========

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

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