How to copy folders - FAKE F # MAKE

I use the CopyFAKE function to copy files from project1 to the release folder, I use the code below:

Target "CopyProject1" (fun _ ->
    !!(buildDir @@ "/_PublishWebsites/Project1/**/*.*")
        |> Copy releaseDir
)

to copy files from the Project1 folder to free the folder, then all the files inside Project1 are copied to the release folder, but I want to maintain the structure of the Project1 folders inside my release folder, that is, I want to copy the Project1 folders for release, is it possible, or will I have to create subfolders inside my release folders and copy one by one. If there is no way to do this, is this possible with a custom task?

If someone can help in this regard, it will be really helpful.

+5
source share
3

CopyWithSubfoldersTo. , :

, FileIncludes, , , BaseDirectory FileIncludes.

, :

Target "CopyProject1" (fun _ ->
    [!!(buildDir @@ "/_PublishWebsites/Project1/**/*.*")]
        |> CopyWithSubfoldersTo releaseDir
)

CopyWithSubfoldersTo seq<FileInculdes>, !! FileIncludes. , .

+3

CopyDir FAKE, , , . :

Target "CopyFoldersTargetLocation" (fun _ ->
    CopyDir targetDir SourceDir allFiles
)
+2

, .NET:

let rec copyFilesRecursively (source: DirectoryInfo) (target: DirectoryInfo) =
    source.GetDirectories()
    |> Seq.iter (fun dir -> CopyFilesRecursively dir (target.CreateSubdirectory dir.Name))
    source.GetFiles()
    |> Seq.iter (fun file -> file.CopyTo(target.FullName @@ file.Name, true) |> ignore)

Target "CopyProject1" <| fun _ ->
    let source = buildDir @@ "/_PublishWebsites/Project1/"
    let target = releaseDir
    copyFilesRecursively (directoryInfo source) (directoryInfo target)
0

Source: https://habr.com/ru/post/1673583/


All Articles