Pre*_*ous 6 msbuild rake 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
Run Code Online (Sandbox Code Playgroud)
我宁愿做一些比较清洁的事情
msbuild :selected_test_projects do |msb, args|
msb.path_to_command = @net40Path
msb.properties :configuration => :Release,
msb.targets [ :Test]
msb.solution = @teststorun
end
Run Code Online (Sandbox Code Playgroud)
Der*_*ley 16
此时,MSBuild任务中没有直接支持构建多个解决方案.但是,有一些选项可用.它主要归结为您最喜欢的语法,但它们都涉及某种循环.
顺便说一下:albacore v0.2.2刚刚发布了几天.它默认为.net 4,并将.path_to_command缩减为.command.但是,由于它是默认的,因此您无需指定要使用的.command.我将在这里使用此语法作为示例.您可以在http://albacorebuild.net上阅读其他发行说明
选项1
将解决方案列表加载到一个数组中,并为每个解决方案调用msbuild.这将附加:具有多个msbuild实例的:build任务,当你调用:build任务时,将构建所有这些实例.
solutions = ["something.sln", "another.sln", "etc"]
solutions.each do |solution|
#loops through each of your solutions and adds on to the :build task
msbuild :build do |msb, args|
msb.properties :configuration => :Release,
msb.targets [:Test]
msb.solution = solution
end
end
Run Code Online (Sandbox Code Playgroud)
在任何其他任务中调用rake build或指定:build为依赖项将构建所有解决方案.
选项#2
选项2与我刚刚显示的基本相同...除了你可以MSBuild直接调用类而不是msbuild任务
msb = MSBuild.new
msb.solution = ...
msb.properties ...
#other settings...
Run Code Online (Sandbox Code Playgroud)
这让你以任何你想要的方式创建一个任务,然后你可以在任何你想要的地方执行你的循环.例如:
task :build_all_solutions do
solutions = FileList["solutions/**/*.sln"]
solutions.each do |solution|
build_solution solution
end
end
def build_solution(solution)
msb = MSBuild.new
msb.properties :configuration => :Release,
msb.targets [:Test]
msb.solution = solution
msb.execute # note: ".execute" replaces ".build" in v0.2.x of albacore
end
Run Code Online (Sandbox Code Playgroud)
现在,当您调用rake build_all_solutions或添加:build_all_solutions为另一个任务的依赖项时,将构建所有解决方案.
...
根据我在这里展示的内容,可能有十几种变化可以完成.但是,它们没有显着差异 - 只需几种不同的方法即可找到所有解决方案,或者循环使用它们.
| 归档时间: |
|
| 查看次数: |
2066 次 |
| 最近记录: |