在进行自动构建时如何处理不同的每个项目构建配置?
在深入研究构建配置继承后,下一个问题出现了:如何处理仅存在于某些包的构建配置?
从命令行构建过去看起来像这样:
msbuild ..\lib\Package1.dproj /target:Build /p:config=%1
msbuild ..\lib\Package2.dproj /target:Build /p:config=%1
msbuild ..\lib\Package3.dproj /target:Build /p:config=%1
参数config
是Debug
或Release
。这很有效。
现在,一些包获得了新的构建配置,例如 Release_Child_Config
(在我的例子中继承自 Release
)。我现在必须做(例如):
msbuild ..\lib\Package1.dproj /target:Build /p:config=Release_Child_Config
msbuild ..\lib\Package2.dproj /target:Build /p:config=Release_Child_Config
msbuild ..\lib\Package3.dproj /target:Build /p:config=Release
在此示例中,Package3
没有名为 Release_Child_Config
的构建配置。这意味着我不能再使用一个 config
参数。
我希望所有具有特殊构建配置 Release_Child_Config
的包都用它来构建,其他包应该回退到 Release
。是否有可能以某种方式实现自动化?或者我是否必须为每个包创建每个构建配置?
After diving deeper into build configuration inheritance the next question comes up: How do I handle build configurations which only exist for some packages?
The build from command line used to look like this:
msbuild ..\lib\Package1.dproj /target:Build /p:config=%1
msbuild ..\lib\Package2.dproj /target:Build /p:config=%1
msbuild ..\lib\Package3.dproj /target:Build /p:config=%1
Parameter config
was either Debug
or Release
. This worked well.
Now some of the packages got new build configurations like Release_Child_Config
(which inherits from Release
in my case). I would now have to do (e.g.):
msbuild ..\lib\Package1.dproj /target:Build /p:config=Release_Child_Config
msbuild ..\lib\Package2.dproj /target:Build /p:config=Release_Child_Config
msbuild ..\lib\Package3.dproj /target:Build /p:config=Release
In this example Package3
doesn't have a build configuration called Release_Child_Config
. This means I cannot use one config
parameter anymore.
I want all packages having the special build configuration Release_Child_Config
to be built with it, the others should fall back to Release
. Is it possible to automate this somehow? Or do I have to create each build configuration for each package?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用这两种配置。如果未启用,则应跳过构建:
或将配置顺序更改为“Release;Release_Child_Config”(发布将首先构建)
Try to use both configurations. If one is not enabled, build should be skipped:
or change config order to "Release;Release_Child_Config" (release will be build first)
在出现更好的结果之前,我的临时解决方案是:通过脚本生成批处理命令。
该脚本会查看每个项目文件 (.dproj) 并执行简单的字符串搜索。如果它找到Release_Child_Config,它会将其写入批处理文件:
如果没有,它会回退到此:
当然,脚本会做更多的事情,因此它也可以用于类似的调试情况 和
Debug_Child_Config
等。到目前为止,它完成了它的工作并适合构建链。Until something better comes up here is my interim solution: Generate the batch commands via script.
The script looks into each of the project files (.dproj) and does a simple string search. If it finds
Release_Child_Config
it writes this to the batch file:If not, it falls back to this:
Of course the script does a bit more so it can also be used for similar cases of
Debug
andDebug_Child_Config
etc. So far it does its job and fits into the build chain.