如何两次调用rake目标

我通过修改.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] 

你可以看到我打电话:在这里建两次。 问题是只有第一个运行。 如果我复制/粘贴我的:构建目标并调用它:Build2并更改:BuildNewDLLs第二次调用:Build2,然后一切正常。 那么我怎么能这样做,以便我可以在:BuildNewDLLs目标中多次调用:Build目标?

提前致谢。

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

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

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

我现在这是一个老问题,但我花了15分钟搞清楚这一点,所以为了文档,这里是:

您可以在要重新启用的同一任务中调用reenable。 由于task块将当前任务作为第一个参数生成,您可以执行以下操作:

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

现在这个工作:

 rake thing thing 
Interesting Posts