如何使用 Albacore 一次构建多个项目?
我正在尝试使用 rake 和 albacore 构建多个 C# 项目。感觉我应该能够在没有循环的情况下做到这一点,但我不能完全让它工作。我要做的是:
msbuild :selected_test_projects do |msb, args|
@teststorun.each do |project|
msb.path_to_command = @net40Path
msb.properties :configuration => :Release,
msb.targets [ :Test]
msb.solution = project
msb.build
end
end
我宁愿做一些更干净的事情,比如这样
msbuild :selected_test_projects do |msb, args|
msb.path_to_command = @net40Path
msb.properties :configuration => :Release,
msb.targets [ :Test]
msb.solution = @teststorun
end
I am trying to build multiple C# projects using rake and albacore. It feels like I should be able to do this without a loop, but I can't quite make it work. What I have to do is this:
msbuild :selected_test_projects do |msb, args|
@teststorun.each do |project|
msb.path_to_command = @net40Path
msb.properties :configuration => :Release,
msb.targets [ :Test]
msb.solution = project
msb.build
end
end
I'd rather do something cleaner, such as this
msbuild :selected_test_projects do |msb, args|
msb.path_to_command = @net40Path
msb.properties :configuration => :Release,
msb.targets [ :Test]
msb.solution = @teststorun
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
目前,MSBuild 任务不直接支持构建多个解决方案。不过,有一些选项可用。这主要取决于您最喜欢哪种语法来执行此操作,但它们都涉及某种循环。
顺便说一句:albacore v0.2.2 几天前刚刚发布。它默认为 .net 4,并将 .path_to_command 缩短为 .command。不过,由于它是默认的,因此您无需指定要使用的 .command。我将在此处的示例中使用此语法。您可以在 http://albacorebuild.net 阅读其他发行说明
选项 #1
加载列表将解决方案放入一个数组中,并为每个解决方案调用 msbuild。这将附加 :build 任务和 msbuild 的多个实例,当您调用 :build 任务时,所有这些实例都将被构建。
在任何其他任务中调用
rake build
或指定:build
作为依赖项将构建您的所有解决方案。选项 #2
选项 2 与我刚才展示的基本相同...除了您可以直接调用
MSBuild
类而不是msbuild
任务这可以让您以任何您希望的方式创建任务,然后您可以在任何您想要的地方执行循环。例如:
现在,当您调用
rake build_all_solutions
或添加:build_all_solutions
作为另一个任务的依赖项时,您的所有解决方案都将被构建。...
根据我在这里展示的内容,可能有十几种可以完成的变体。但是,它们并没有显着差异 - 只是找到所有解决方案或循环遍历它们的几种不同方法。
At this point, there's no direct support in the MSBuild task for building multiple solutions.There are a few options available, though. It mostly comes down to what syntax you like the best for doing this, but they all involve a loop of some sort.
By the way: albacore v0.2.2 was just release a few days ago. It defaults to .net 4, and shortens the .path_to_command down to .command. Since it defaults, though, you don't need to specify the .command to use. I'll use this syntax for the examples, here. You can read additional release notes at http://albacorebuild.net
Option #1
Load the list of solutions into an array and call msbuild for each solution. this will append the :build task with multiple instances of msbuild and when you call the :build task, all of them will be built.
calling
rake build
or specifying:build
as a dependency in any other task will build all of your solutions.Option #2
option 2 is basically the same what I just showed... except you can call the
MSBuild
class directly instead of themsbuild
taskthis let's you create a task any way you wish, and then you can perform your loop wherever you want. For example:
Now, when you call
rake build_all_solutions
or you add:build_all_solutions
as a dependency on another task, all of your solutions will be built....
there are probably have a dozen variations that can be done, based on what I've shown here. However, they don't differ significantly - just a few different ways to find all the solutions, or loop through them.