构建具有多个项目和多个配置的解决方案
Visual Studio 2010 Premium,本机 WIN32 MFC 项目(解决方案中没有 .net 项目)。
我们有一个包含 35 个项目的复杂解决方案。我们有许多该产品的客户,我们通常所做的是为每个客户创建单独的配置。除了一些 #define 和输出目录的更改之外,配置没有任何重大更改。它运行良好,但现在产品的每次更改都需要更改多个配置,并且也容易出错。我们希望根据某些参数仅使用一种通用配置来清理多个配置,并将这些参数通过批处理文件传递以进行构建。
为客户“A”构建 条件编译 #define _BUILD_PROJECT_FOR "A" 它的输出文件夹位于“c:\builds\client\a”中 在解决方案中的 35 个项目中,我们只需要为该客户端提供 32 个项目
要传递什么命令和参数,以便我只需传递 #ifdef、要构建的项目及其输出目录即可在命令行构建解决方案。
我正在尝试使用 msbuild 但无法将预处理器参数传递给编译器。
Visual Studio 2010 Premium, Native WIN32 MFC Project (no .net project in solution).
We have a complex solution with 35 projects. We have many clients for that product and what we normally do was to create a separate configuration for each client. Configuration did not have any major changes except few #define and changes to output directory. It was working fine but now with each change in product requires change in multiple configuration and is also error prone. We want to clean up multiple configurations with just one generic configuration depending on certain parameters and passing those parameters through a batch file for building builds.
to build for a client 'A'
conditional compilation #define _BUILD_PROJECT_FOR "A"
its output folder is in "c:\builds\client\a"
out of 35 projects in solution we need only 32 projects for that client
What command and parameters to pass so that I can build a solution at command line by just passing #ifdef, what projects to build and their output directory.
I am trying with msbuild but unable to pass to compiler the preprocessor arguments.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于预处理器指令,您可以查看这个 上一个问题。
For the preprocessor directives, you can check out this previous question.
更多帮助可以从:
http://www.sysnet.pe.kr/Default.aspx?mode=2&sub=0&pageno=0&detail=1&wid=第871章&标题=%25vc%2B%2B%25
More help can be taken from:
http://www.sysnet.pe.kr/Default.aspx?mode=2&sub=0&pageno=0&detail=1&wid=871&title=%25vc%2B%2B%25
这对我有用。
使用 VS2010,我有几个项目正在进行中,所有这些项目都需要从一个公共项目中 #include 一些 .h 文件,我将它们作为共享 .h 文件保留在那里。如果我在正在处理的项目中使用类似 #define ACTION 的内容,则在编译时使用 #ifdef ACTION 时,任何共享项目文件都不会识别它。为了解决这个问题,我没有在工作项目中添加#define ACTION,而是将其添加到命令行选项中。
您可以在“项目属性”、“C/C++ >>”下找到此内容。在命令行中,在“附加选项”框中输入 /D“ACTION”。就编译器而言,这与#define ACTION 相同。
附加说明,我还得“添加”添加>>我想将共享项目中的 .h 和 .cpp 共享文件的现有项目使用到我的工作项目中,以满足我抱怨的链接器。
我希望这有帮助。
This works for me.
Using VS2010, I have several projects on the go and all of them needs to #include a few .h files from a common project where I sort of keep them there as shared .h files. If I use something like #define ACTION in the project I am working with, it won't be recognized in any of the shared project files when using #ifdef ACTION while compiling. To resolve that issue, instead of adding #define ACTION in the working project, I add it to the command line option.
You get this under Project Properties, C/C++ >> Command Line, enter /D "ACTION" in the Additional Option box. It's the same as saying #define ACTION as far as the compiler is concerned.
Additional notes, I also had to "Add" Add >> Existing Items, of the .h and .cpp shared files I wanted to use from my shared project into my working project to satisfy my complaining linker.
I hope this helps.