我想将特定目录中的所有文件复制到目标目录 我的代码运行正常但没有文件被复制到目标文件夹。
我尝试了两种方法,但没有运气:(
这是我的代码:
#r @"packages\FAKE\tools\FakeLib.dll"
open Fake
let buildDir = "D:/MyDir/build/"
let testDir = "D:/MyDir/test/"
let sourceDir = "D:/Files"
// Targets
Target "Clean" (fun _ ->
CleanDirs [buildDir; testDir]
)
Target "BuildSetup" (fun _ ->
!!(sourceDir + "\**\*.txt")
|> Copy testDir)
"Clean"
==>"BuildSetup"
RunTargetOrDefault "BuildSetup"
#r @"packages\FAKE\tools\FakeLib.dll"
open Fake
let buildDir = "D:/MyDir/build/"
let testDir = "D:/MyDir/test/"
let sourceDir = "D:/Files"
// Targets
Target "Clean" (fun _ ->
CleanDirs [buildDir; testDir ;sourceDir]
)
Target "Default" (fun _ ->
trace "Hello World from FAKE"
)
let additionalFiles = ["D:\Files\new\*.*"]
Target "CopyFiles" (fun _ ->
CopyTo buildDir additionalFiles
)
Target "BuildSetup" (fun _ ->
!!("D:\Files\new\*.txt")
|> Copy buildDir)
"Clean"
//==> "Clean"
//==> "BuildStep"
==> "CopyFiles"
RunTargetOrDefault "BuildSetup"
正在运行此代码,但文件未复制到目标文件夹。
请告诉我问题的根本原因,我是假的新手。答案 0 :(得分:4)
以下是一个工作示例:
#r "./packages/FAKE/tools/FakeLib.dll"
open Fake
let source = "C:/test/source"
let additionalFilesDir = "C:/test/additional"
let dest = "C:/test/dest/"
Target "Clean" (fun _ ->
CleanDirs [dest]
)
Target "Default" (fun _ ->
trace "Hello World from FAKE"
)
Target "CopyDirectory" (fun _ ->
CopyDir (directory dest) source allFiles
)
Target "CopyAdditionalFiles" (fun _ ->
!!(additionalFilesDir @@ "**/*")
--(additionalFilesDir @@ "**/*.txt") //exclude '.txt' files
|> Copy dest
//copy will NOT fail if directory not existing
if not <|directoryExists additionalFilesDir then
traceError ("additionalFilesDir doesn't exist:" + additionalFilesDir)
)
"Clean"
==> "CopyDirectory"
==> "CopyAdditionalFiles"
==> "Default"
RunTargetOrDefault "Default"