2010-12-09 4 views
6

rake와 albacore를 사용하여 여러 C# 프로젝트를 작성하려고합니다. 루프없이이 작업을 수행 할 수 있어야하는 것처럼 느껴지지만 작동시키지 못합니다. 여러 솔루션을 구축하기위한 MSBuild를 작업에 직접 지원 없다, 그런이 시점에서이Albacore를 사용하여 한 번에 여러 프로젝트를 만들려면 어떻게해야합니까?

msbuild :selected_test_projects do |msb, args| 
    msb.path_to_command = @net40Path 
    msb.properties :configuration => :Release, 
    msb.targets [ :Test] 
    msb.solution = @teststorun 
end 

답변

16

로,

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 

차라리 뭔가 청소기를 할 거라고 : 내가해야 할 일은 이것이다. 그러나 몇 가지 옵션을 사용할 수 있습니다. 대부분이 구문을 사용하기에 가장 좋아하는 문법으로 바뀌지 만 모두 일종의 루프를 포함합니다.

덧붙여서 : albacore v0.2.2는 불과 며칠 전에 릴리스되었습니다. 기본값은 .net 4이며 .path_to_command를 .command로 줄입니다. 디폴트이기 때문에 .command를 사용할 필요가 없습니다. 예제에서는이 구문을 사용합니다. 각 솔루션에 대한 배열 및 전화를 msbuild로 1

로드에게 http://albacorebuild.net

옵션 #에서 솔루션의 목록을 추가 릴리스 노트를 읽을 수 있습니다. 이렇게하면 : build 작업을 msbuild의 여러 인스턴스와 추가하고 : 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 

rake build를 호출하거나 모든 솔루션을 구축 할 것입니다 다른 작업의 종속성으로 :build를 지정.

옵션 # 옵션 2는 직접 대신 msbuild 작업의 MSBuild 클래스를 호출 할 수 있습니다 제외하고 난 그냥 ... 보여 무엇을 기본적으로 동일 2

msb = MSBuild.new 
msb.solution = ... 
msb.properties ... 
#other settings... 

이하자가 만든 원하는대로 작업을 수행 한 다음 원할 때마다 루프를 수행 할 수 있습니다. 예를 들어 :

이제
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 

, 당신은 rake build_all_solutions 전화를 걸거나 다른 작업에 종속성으로 :build_all_solutions를 추가, 솔루션의 모든 내장됩니다.

...

은 아마 내가 여기에 표시 한 내용을 기반으로 수행 할 수 십여 변동이있을 수 있습니다. 그러나 모든 솔루션을 찾거나 루프를 반복하는 몇 가지 다른 방법이 있습니다.

관련 문제