简体   繁体   English

如何两次调用rake目标

[英]How to call rake target twice

I generate two different sets of DLL files from my .sln by modifying the .csproj files to include an extra compilation symbol. 我通过修改.csproj文件以包含额外的编译符号,从我的.sln生成两组不同的DLL文件。 I'm using rake to build the solution, and have the following Build task: 我正在使用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

I then try to generate both sets of DLL files using: 然后我尝试使用以下方法生成两组DLL文件:

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

You can see that I call :Build twice here. 你可以看到我打电话:在这里建两次。 The problem is that only the first one runs. 问题是只有第一个运行。 If I copy/paste my :Build target and call it :Build2 and change :BuildNewDLLs to call :Build2 the second time, then everything works fine. 如果我复制/粘贴我的:构建目标并调用它:Build2并更改:BuildNewDLLs第二次调用:Build2,然后一切正常。 So how can I make it so that I can call the :Build target multiple times from within the :BuildNewDLLs target? 那么我怎么能这样做,以便我可以在:BuildNewDLLs目标中多次调用:Build目标?

Thanks in advance. 提前致谢。

I know this is an old question, but I just spent 15 minutes figuring this out, so for the sake of documentation, here goes: 我知道这是一个老问题,但我花了15分钟搞清楚这一点,所以为了文档,这里有:

You can call reenable from within the same task that you wish to reenable. 您可以拨打reenable了您想要重新启用相同的任务范围内。 And since the task block yields the current task as first argument, you can do: 由于task块将当前任务作为第一个参数生成,您可以执行以下操作:

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

And now this works: 现在这个工作:

rake thing thing

Rake will, by default, ensure that each rake task is executed once and only once per session. 默认情况下,Rake将确保每个rake任务执行一次,每个会话只执行一次。 You can re-enable your build task with the following code. 您可以使用以下代码重新启用构建任务。

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

That will allow it to be re-executed in the same session. 这将允许它在同一个会话中重新执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM