ruby - 如何调用 rake 目标两次

标签 ruby build msbuild rake target

我通过修改 .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 目标?

提前致谢。

最佳答案

我知道这是一个老问题,但我只花了 15 分钟来解决这个问题,所以为了文档起见,这里是:

您可以在您希望重新启用的同一任务中调用reenable。由于 task block 将当前任务作为第一个参数,您可以:

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

现在可以了:

rake thing thing

关于ruby - 如何调用 rake 目标两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10391834/

相关文章:

ruby - Jekyll 服务错误:找不到 gem jekyll (>= 0.a) (Gem::GemNotFoundException

ruby-on-rails - 写入包含宏的现有 Excel .xls 文件

java - libGDX 应用程序到 .exe?

asp.net - 如何使用msbuild发布网页?

ruby-on-rails - 在ruby中将 Camel 大小写转换为下划线大小写

ruby-on-rails - 无法在 Mac OS X 10.8.4 上安装 json 1.8 gem

plugins - jenkins 插件显示当天的构建摘要

windows - 如何在 Windows 上使用 MinGW 构建 OpenCV 3.2.0

tfs - 不明白构建定义中的类别过滤器

c# - 在csproj中使用通配符时如何在xaml文件下嵌套xaml.cs