3

我通过修改 .csproj 文件以包含额外的编译符号,从我的 .sln 生成两组不同的 DLL 文件。我正在使用 rake 构建解决方案,并具有以下构建任务:

#==========================================================
desc "Builds the DPSF.sln in Release mode."
msbuild :Build do |msb|
    puts 'Building the DPSF solution...'
    msb.properties :configuration => :Release
    msb.targets [:Clean, :Rebuild]
    msb.solution = DPSF_SOLUTION_FILE_PATH
    msb.parameters "/nologo", "/maxcpucount", "/fileLogger", "/noconsolelogger"
    msb.verbosity = "quiet" # Use "diagnostic" instead of "quiet" for troubleshooting build problems.

    # Delete the build log file if the build was successful (otherwise the script will puke before this point).
    File.delete('msbuild.log')
end

然后我尝试使用以下方法生成两组 DLL 文件:

desc "Builds new regular and AsDrawableGameComponent DLLs."
task :BuildNewDLLs => [:DeleteExistingDLLs, :Build, :UpdateCsprojFilesToBuildAsDrawableGameComponentDLLs, :Build, :RevertCsprojFilesToBuildRegularDLLs]

你可以看到我在这里调用 :Build 两次。问题是只有第一个运行。如果我复制/粘贴我的 :Build 目标并调用它 :Build2 并更改 :BuildNewDLLs 以第二次调用 :Build2 ,那么一切正常。那么如何才能让我可以从 :BuildNewDLLs 目标中多次调用 :Build 目标呢?

提前致谢。

4

2 回答 2

7

I know this is an old question, but I just spent 15 minutes figuring this out, so for the sake of documentation, here goes:

You can call reenable from within the same task that you wish to reenable. And since the task block yields the current task as first argument, you can do:

task :thing do |t|
  puts "hello"
  t.reenable
end

And now this works:

rake thing thing
于 2013-12-08T21:58:51.157 回答
6

默认情况下,Rake 将确保每个 rake 任务在每个会话中执行一次且仅执行一次。您可以使用以下代码重新启用构建任务。

::Rake.application['Build'].reenable

这将允许它在同一个会话中重新执行。

于 2012-04-30T23:43:56.460 回答