diff --git a/Samples/ContinuousDeploymentWebsite/build.fsx b/Samples/ContinuousDeploymentWebsite/build.fsx index c07d0310512..d8da63cdd2d 100644 --- a/Samples/ContinuousDeploymentWebsite/build.fsx +++ b/Samples/ContinuousDeploymentWebsite/build.fsx @@ -38,9 +38,8 @@ Target "AssemblyInfo" (fun _ -> ) Target "BuildApp" (fun _ -> - !+ @"src\app\**\*.csproj" + !! @"src\app\**\*.csproj" ++ @"src\app\**\*.fsproj" - |> Scan |> MSBuildRelease buildDir "Build" |> Log "Build-Output: " ) diff --git a/Samples/SideBySideSpecification/build.fsx b/Samples/SideBySideSpecification/build.fsx index 0c85f59a94c..8f7ca5f9daf 100644 --- a/Samples/SideBySideSpecification/build.fsx +++ b/Samples/SideBySideSpecification/build.fsx @@ -16,10 +16,9 @@ let fxCopRoot = @".\Tools\FxCop\FxCopCmd.exe" // Filesets let appReferences = - !+ @"src\app\**\*.csproj" + !! @"src\app\**\*.csproj" ++ @"src\app\**\*.fsproj" - -- "**\*_Spliced*" - |> Scan + -- "**\*_Spliced*" // version info let version = "0.2" // or retrieve from CI server @@ -61,9 +60,8 @@ Target "Test" (fun _ -> ) Target "Deploy" (fun _ -> - !+ (buildDir + "\**\*.*") - -- "*.zip" - |> Scan + !! (buildDir + "\**\*.*") + -- "*.zip" |> Zip buildDir (deployDir + "Calculator." + version + ".zip") ) diff --git a/build.fsx b/build.fsx index 3b43b74299b..623bb3bb57e 100644 --- a/build.fsx +++ b/build.fsx @@ -132,10 +132,9 @@ Target "CopyLicense" (fun _ -> ) Target "BuildZip" (fun _ -> - !+ (buildDir @@ @"**/*.*") + !! (buildDir @@ @"**/*.*") -- "*.zip" -- "**/*.pdb" - |> Scan |> Zip buildDir deployZip ) diff --git a/help/fxcop.md b/help/fxcop.md index eba475ff1c6..81ee41a8698 100644 --- a/help/fxcop.md +++ b/help/fxcop.md @@ -10,9 +10,8 @@ Open *build.fsx* from your Calculator sample folder and add a new target *FxCop* Target "FxCop" (fun () -> let assemblies = - !+ (buildDir + @"\**\*.dll") + !! (buildDir + @"\**\*.dll") ++ (buildDir + @"\**\*.exe") - |> Scan FxCop (fun p -> @@ -44,9 +43,8 @@ If you want to let the build fail in the case that FxCop reports any errors or w Target "FxCop" (fun () -> let assemblies = - !+ (buildDir + @"\**\*.dll") - ++ (buildDir + @"\**\*.exe") - |> Scan + !! (buildDir + @"\**\*.dll") + ++ (buildDir + @"\**\*.exe") FxCop (fun p -> diff --git a/help/gettingstarted.md b/help/gettingstarted.md index e286a5739fc..2b37c923869 100644 --- a/help/gettingstarted.md +++ b/help/gettingstarted.md @@ -330,9 +330,8 @@ Now we want to deploy a *.zip file containing our application: ) Target "Zip" (fun _ -> - !+ (buildDir + "\**\*.*") - -- "*.zip" - |> Scan + !! (buildDir + "\**\*.*") + -- "*.zip" |> Zip buildDir (deployDir + "Calculator." + version + ".zip") ) diff --git a/help/index.md b/help/index.md index d3b0fc15311..9604e843c0e 100644 --- a/help/index.md +++ b/help/index.md @@ -120,48 +120,19 @@ These targets will be executed even if the build fails but have to be activated ### File includes - // Includes all *.csproj files under /src/app by using the !+ operator - !+ "src/app/**/*.csproj" + // Includes all *.csproj files under /src/app by using the !! operator + !! "src/app/**/*.csproj" // Includes all *.csproj files under /src/app and /test with the ++ operator - !+ "src/app/**/*.csproj" + !! "src/app/**/*.csproj" ++ "test/**/*.csproj" ### File excludes // Includes all files under /src/app but excludes *.zip files - !+ "src/app/**/*.*" + !! "src/app/**/*.*" -- "*.zip" -### Scan vs. ScanImmediately - -"FAKE - F# Make" provides two scan methods: Scan() and ScanImmediately(). - -Scan is a lazy method and evaluates the FileSet as late as possible ("on-demand"). -If the FileSet is used twice, it will be reevaluated. - -The following code defines a lazy FileSet: - - // Includes all *.csproj files under /src/app and scans them lazy - let apps = - !+ "src/app/**/*.csproj" - |> Scan - -The same FileSet by using the !! operator: - - // Includes all *.csproj files under /src/app and scans them lazy - let apps = !! "src/app/**/*.csproj" - -ScanImmediately() scans the FileSet immediatly at time of its definition -and memoizes it. - - // Includes all files under /src/app but excludes *.zip files - // eager scan ==> All files memoized at the time of this definition - let files = - !+ "src/app/**/*.csproj" - -- "*.zip" - |> ScanImmediately - ## UnitTests ### NUnit @@ -236,9 +207,8 @@ You can read the [getting started guide](gettingstarted.html) to build such a sc // Filesets let appReferences = - !+ @"src\app\**\*.csproj" - ++ @"src\app\**\*.fsproj" - |> Scan + !! @"src\app\**\*.csproj" + ++ @"src\app\**\*.fsproj" let testReferences = !! @"src\test\**\*.csproj" @@ -301,9 +271,8 @@ You can read the [getting started guide](gettingstarted.html) to build such a sc ) Target "FxCop" (fun _ -> - !+ (buildDir + @"\**\*.dll") - ++ (buildDir + @"\**\*.exe") - |> Scan + !! (buildDir + @"\**\*.dll") + ++ (buildDir + @"\**\*.exe") |> FxCop (fun p -> {p with ReportFileName = testDir + "FXCopResults.xml"; @@ -311,9 +280,8 @@ You can read the [getting started guide](gettingstarted.html) to build such a sc ) Target "Deploy" (fun _ -> - !+ (buildDir + "\**\*.*") + !! (buildDir + "\**\*.*") -- "*.zip" - |> Scan |> Zip buildDir (deployDir + "Calculator." + version + ".zip") ) diff --git a/src/app/FakeLib/FileHelper.fs b/src/app/FakeLib/FileHelper.fs index 74256487c67..e7184dd7015 100644 --- a/src/app/FakeLib/FileHelper.fs +++ b/src/app/FakeLib/FileHelper.fs @@ -47,9 +47,8 @@ let DeleteDir path = let dir = directoryInfo path if dir.Exists then // set all files readonly = false - !+ "/**/*.*" + !! "/**/*.*" |> SetBaseDir dir.FullName - |> Scan |> (SetReadOnly false) logfn "Deleting %s" dir.FullName diff --git a/src/app/FakeLib/FileSet.fs b/src/app/FakeLib/FileSet.fs index f1bf8323841..f51eb8f4e7d 100644 --- a/src/app/FakeLib/FileSet.fs +++ b/src/app/FakeLib/FileSet.fs @@ -2,19 +2,12 @@ /// Contains abstractions which allow to use file globbing. module Fake.FileSetHelper +open System open System.IO open System.Globalization open System.Text open System.Text.RegularExpressions -/// The FileSet is eagerly loaded into a list of strings. -/// The scan is only done once. -type EagerFileSet = string list - -/// The FileSet is lazy loaded into a sequence of strings. -/// Every time the FileSet is used it scans again. -type LazyFileSet = string seq - /// [omit] /// Internal representation type RegexEntry = @@ -22,12 +15,6 @@ type RegexEntry = BaseDirectory: string; Pattern: string} -/// Internal representation of a file set -type FileIncludes = - { BaseDirectories: string list; - Includes: string list; - Excludes: string list} - /// Patterns can use either / \ as a directory separator. /// This function creates a StringBuilder which replaces both of these characters with Path.DirectorySeparatorChar let cleanPathBuilder (path:string) = @@ -339,16 +326,28 @@ let Log message files = files |> Seq.iter (log << sprintf "%s%s" message) /// The default base directory (the current directory). let DefaultBaseDir = Path.GetFullPath "." + +/// Internal representation of a file set +type FileIncludes = + { BaseDirectories: string list; + Includes: string list; + Excludes: string list} + + interface IEnumerable with + member this.GetEnumerator() = (Files this.BaseDirectories this.Includes this.Excludes).GetEnumerator() + member this.GetEnumerator() = (Files this.BaseDirectories this.Includes this.Excludes).GetEnumerator():> System.Collections.IEnumerator + /// Include files let Include x = { BaseDirectories = [DefaultBaseDir]; Includes = [x]; - Excludes = []} + Excludes = []} /// Lazy scan for include files. /// Will be processed at the time when needed. -let Scan includes : LazyFileSet = Files includes.BaseDirectories includes.Includes includes.Excludes +[ so explicit scanning is not needed")>] +let Scan files = files /// Adds a directory as baseDirectory for fileIncludes. let AddBaseDir dir fileInclude = {fileInclude with BaseDirectories = dir::fileInclude.BaseDirectories} @@ -357,9 +356,11 @@ let AddBaseDir dir fileInclude = {fileInclude with BaseDirectories = dir::fileIn let SetBaseDir (dir:string) fileInclude = {fileInclude with BaseDirectories = [dir.TrimEnd(directorySeparator.[0])]} /// Scans immediately for include files - all matching files will be memoized. -let ScanImmediately includes : EagerFileSet = Scan includes |> Seq.toList +[ so explicit scanning is not needed. Just use Seq.toList")>] +let ScanImmediately includes = includes |> Seq.toList /// Include prefix operator +[] let inline (!+) x = Include x /// Add Include operator @@ -369,7 +370,7 @@ let inline (++) x y = {x with Includes = y::x.Includes} let inline (--) x y = {x with Excludes = y::x.Excludes} /// Includes a single pattern and scans the files - !! x = AllFilesMatching x -let inline (!!) x = !+ x |> Scan +let inline (!!) x = Include x /// Includes a single pattern and scans the files - !! x = AllFilesMatching x let AllFilesMatching x = !! x diff --git a/src/app/FakeLib/MSBuildHelper.fs b/src/app/FakeLib/MSBuildHelper.fs index 2c5289ba3ac..fab8c6fd869 100644 --- a/src/app/FakeLib/MSBuildHelper.fs +++ b/src/app/FakeLib/MSBuildHelper.fs @@ -240,7 +240,7 @@ let MSBuildWithProjectProperties outputPath (targets: string) (properties: strin |> List.iter (fun project -> build (setBuildParam project) project) // it makes no sense to output the root dir content here since it does not contain the build output - if isNotNullOrEmpty output then !! (outputPath @@ "/**/*.*") else Seq.empty + if isNotNullOrEmpty output then !! (outputPath @@ "/**/*.*") |> Seq.toList else [] /// Builds the given project files or solution files and collects the output files. /// ## Parameters diff --git a/src/app/FakeLib/WiXHelper.fs b/src/app/FakeLib/WiXHelper.fs index 43db8e98e57..b0b430e7bde 100644 --- a/src/app/FakeLib/WiXHelper.fs +++ b/src/app/FakeLib/WiXHelper.fs @@ -1,4 +1,4 @@ -[] +[] /// Contains tasks to create msi installers using the [WiX toolset](http://wixtoolset.org/) module Fake.WiXHelper @@ -123,10 +123,9 @@ let Light (parameters:WiXParams) outputFile wixObj = /// ## Sample /// Target "BuildSetup" (fun _ -> /// // Copy all important files to the deploy directory -/// !+ (buildDir + "/**/*.dll") +/// !! (buildDir + "/**/*.dll") /// ++ (buildDir + "/**/*.exe") /// ++ (buildDir + "/**/*.config") -/// |> Scan /// |> Copy deployPrepDir /// /// // replace tags in a template file in order to generate a WiX script diff --git a/src/test/Test.FAKECore/FileHandling/BaseFunctions.cs b/src/test/Test.FAKECore/FileHandling/BaseFunctions.cs index 2d27bf09ea4..3fec0101390 100644 --- a/src/test/Test.FAKECore/FileHandling/BaseFunctions.cs +++ b/src/test/Test.FAKECore/FileHandling/BaseFunctions.cs @@ -111,10 +111,7 @@ public static List Scan(string pattern, string baseDir) { TraceHelper.trace(string.Format("Scan for {0} in {1}:", pattern, baseDir)); - var list = - FileSetHelper.Scan( - FileSetHelper.SetBaseDir(baseDir, - FileSetHelper.Include(pattern))).ToList(); + var list = FileSetHelper.SetBaseDir(baseDir, FileSetHelper.Include(pattern)).ToList(); foreach (var file in list) TraceHelper.trace(string.Format(" - {0}", file)); return list; diff --git a/src/test/Test.FAKECore/Globbing/Directories/build.fsx b/src/test/Test.FAKECore/Globbing/Directories/build.fsx index e2444d1b2b0..cbd8a1841c0 100644 --- a/src/test/Test.FAKECore/Globbing/Directories/build.fsx +++ b/src/test/Test.FAKECore/Globbing/Directories/build.fsx @@ -3,7 +3,6 @@ open System open Fake -!+ "SampleApp\\bin\\*" +!! "SampleApp\\bin\\*" // -- "SampleApp\\bin" -|> Scan |> Seq.iter (printfn "scanned %s") diff --git a/src/test/Test.FAKECore/Globbing/Excludes/GlobbingOfDirectoriesSpecs.cs b/src/test/Test.FAKECore/Globbing/Excludes/GlobbingOfDirectoriesSpecs.cs index a84c10c2d40..60d66cd83f0 100644 --- a/src/test/Test.FAKECore/Globbing/Excludes/GlobbingOfDirectoriesSpecs.cs +++ b/src/test/Test.FAKECore/Globbing/Excludes/GlobbingOfDirectoriesSpecs.cs @@ -1,8 +1,8 @@ -using System.IO; -using System.Linq; +using System.Linq; using Fake; using Machine.Specifications; using Test.FAKECore.FileHandling; + namespace Test.FAKECore.Globbing.Excludes { public class when_extracting_sample_zip : BaseFunctions