简体   繁体   English

将所有文件复制到Fake fake中的目标目录中

[英]Copy all files to the destination directory in Fake f#make

I want to copy all files in a particular directory to destination directory. 我想将特定目录中的所有文件复制到目标目录。
My code is running perfectly but no files are being copied to the destination folder . 我的代码运行正常,但是没有文件被复制到目标文件夹。

I have tried two approaches but no luck :( 我尝试了两种方法,但是没有运气:(
Here is my code: 这是我的代码:

Approach 1: 方法1:

#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"

Approach 2 : 方法2:

#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"

this code is being run , but files are not copied to the destination folder . 此代码正在运行,但文件不会复制到目标文件夹。

please tell me root cause of the problem , I am new to fake . 请告诉我问题的根本原因,我是新手。

The below is a working example: 下面是一个工作示例:

#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"

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

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