From 8ba28f039612fe452783e80a10fadbdb0bb99a78 Mon Sep 17 00:00:00 2001 From: Julien Roncaglia Date: Thu, 17 Sep 2015 13:33:46 +0200 Subject: [PATCH 1/3] Don't polute the environment in build.cmd build.cmd wasn't using SETLOCAL but was using SET on an environment variable named 'TARGET' that was leaking out of the script. The 'TARGET' variable was also adding needless quotes to the name of the target (That were later trimed due to argument processing but still needless) --- build.cmd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.cmd b/build.cmd index 52423f3105e..ddc8b4637fd 100644 --- a/build.cmd +++ b/build.cmd @@ -1,4 +1,5 @@ @echo off +SETLOCAL cls @@ -12,8 +13,8 @@ if errorlevel 1 ( exit /b %errorlevel% ) -SET TARGET="Default" +SET TARGET=Default -IF NOT [%1]==[] (set TARGET="%1") +IF NOT [%1]==[] (SET TARGET=%1) "packages\FAKE\tools\Fake.exe" "build.fsx" "target=%TARGET%" \ No newline at end of file From 39197720528efa8bfbba47379204af2a11845e5a Mon Sep 17 00:00:00 2001 From: Julien Roncaglia Date: Thu, 17 Sep 2015 13:39:54 +0200 Subject: [PATCH 2/3] Don't throw KeyNotFound on invalid target name The dictionary of targets was sometimes acceded directly and was throwing KeyNotFoundException. The getTarget helper is now used everywhere, providing the name of the invalid target and also printing the list of valid target on the console. --- src/app/FakeLib/TargetHelper.fs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/FakeLib/TargetHelper.fs b/src/app/FakeLib/TargetHelper.fs index acf5fffdf3d..8bcf63396b6 100644 --- a/src/app/FakeLib/TargetHelper.fs +++ b/src/app/FakeLib/TargetHelper.fs @@ -302,7 +302,7 @@ let runFinalTargets() = let watch = new System.Diagnostics.Stopwatch() watch.Start() tracefn "Starting FinalTarget: %s" name - TargetDict.[toLower name].Function() + (getTarget name).Function() addExecutedTarget name watch.Elapsed with | exn -> targetError name exn) @@ -318,7 +318,7 @@ let runBuildFailureTargets() = let watch = new System.Diagnostics.Stopwatch() watch.Start() tracefn "Starting BuildFailureTarget: %s" name - TargetDict.[toLower name].Function() + (getTarget name).Function() addExecutedTarget name watch.Elapsed with | exn -> targetError name exn) @@ -335,7 +335,7 @@ let PrintTargets() = let private withDependencyType (depType:DependencyType) targets = targets |> List.map (fun t -> depType, t) -// Helper function for visiting targets in a dependency tree. Retutrns a set containing the names of the all the +// Helper function for visiting targets in a dependency tree. Returns a set containing the names of the all the // visited targets, and a list containing the targets visited ordered such that dependencies of a target appear earlier // in the list than the target. let private visitDependencies fVisit targetName = @@ -343,7 +343,7 @@ let private visitDependencies fVisit targetName = let visited = new HashSet<_>() let ordered = new List<_>() let rec visitDependenciesAux level (depType,targetName) = - let target = TargetDict.[toLower targetName] + let target = getTarget targetName let isVisited = visited.Contains targetName visited.Add targetName |> ignore fVisit (target, depType, level, isVisited) From a90741a92f71551b6617f7f86027d14b79d44a74 Mon Sep 17 00:00:00 2001 From: Julien Roncaglia Date: Thu, 17 Sep 2015 13:50:55 +0200 Subject: [PATCH 3/3] Gracefuly handle additional quotes in build.cmd Both of the following invocations are now equivalent build.cmd Test build.cmd "Test" --- build.cmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.cmd b/build.cmd index ddc8b4637fd..ee316b07f6c 100644 --- a/build.cmd +++ b/build.cmd @@ -15,6 +15,6 @@ if errorlevel 1 ( SET TARGET=Default -IF NOT [%1]==[] (SET TARGET=%1) +IF NOT [%1]==[] (SET TARGET=%~1) -"packages\FAKE\tools\Fake.exe" "build.fsx" "target=%TARGET%" \ No newline at end of file +"packages\FAKE\tools\Fake.exe" "build.fsx" "target="%TARGET%"" \ No newline at end of file