创建复制目录和文件的任务时出现xcopy错误

时间:2018-01-18 15:10:43

标签: sbt

我想在Windows10中使用sbt创建xcopy任务来复制目录和文件。我收到了以下错误。这是什么错误?

val copyCommonFilesInPublicKey = taskKey[Int]("Copies files in ../common/css and ../common/javascripts in public/stylesheet/common and public/javascripts/common")

copyCommonFilesInPublicKey := {
    val copyCSS = Process(s"xcopy  /i ../common/css public/stylesheets/common").!< //I had to use / instead of \ in path
    println(s"copy CSS returned ${copyCSS}")
    val copyJS = Process(s"xcopy  /i ../common/javascripts public/javascripts/common").!<
    println(s"copy JS returned ${copyJS}")
    copyJS
}

错误

Invalid number of parameters
copy CSS returned 4
Invalid number of parameters
copy JS returned 4
[success] Total time: 0 s, completed 18-Jan-2018 15:03:32

命令在cmd上正常运行。我怀疑这可能是/i的问题,因为我无法通过使用\提供路径来运行命令。我尝试将/i更改为\\i但我收到同样的错误。

1 个答案:

答案 0 :(得分:0)

您需要拆分参数:

    val copyCommonFilesInPublicKey = taskKey[Int]("Copies files in ../common/css and ../common/javascripts in public/stylesheet/common and public/javascripts/common")

copyCommonFilesInPublicKey := {
    val copyCSS = Process(Seq("xcopy", "/i", "..\\common\\css", "public\\stylesheets\\common")).!<
    println(s"copy CSS returned ${copyCSS}")
    val copyJS = Process(Seq("xcopy", "/i", "..\\common\\javascripts", "public\\javascripts\\common")).!<
    println(s"copy JS returned ${copyJS}")
    copyJS
}