From f7abca77286c7286010f4f0f5c7cc7bac7fd69d2 Mon Sep 17 00:00:00 2001 From: Vasily Kirichenko Date: Thu, 12 Feb 2015 10:43:04 +0300 Subject: [PATCH 1/2] remove unused parameter --- src/app/Fake.Deploy/DeploymentAgent.fs | 11 ++++------- src/app/Fake.Deploy/DeploymentHelper.fs | 14 ++++++-------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/app/Fake.Deploy/DeploymentAgent.fs b/src/app/Fake.Deploy/DeploymentAgent.fs index 595b212ec21..725836960ee 100644 --- a/src/app/Fake.Deploy/DeploymentAgent.fs +++ b/src/app/Fake.Deploy/DeploymentAgent.fs @@ -2,13 +2,10 @@ open System open System.IO -open System.Net -open System.Threading open System.Diagnostics open Fake open Fake.DeploymentHelper open Fake.DeployAgentModule -open Fake.HttpListenerHelper open Nancy open Nancy.Hosting.Self open Nancy.Security @@ -30,7 +27,7 @@ let runDeployment workDir (ctx : Nancy.Request) = let packageBytes = getBodyFromNancyRequest ctx let package, scriptFile = unpack workDir false packageBytes let scriptArguments = getScriptArgumentsFromNancyRequest ctx - let response = doDeployment package.Name scriptFile scriptArguments + let response = doDeployment scriptFile scriptArguments match response with | FakeDeployAgentHelper.Success _ -> logger (sprintf "Successfully deployed %s %s" package.Id package.Version, EventLogEntryType.Information) @@ -62,10 +59,10 @@ type DeployAgentModule() as http = http.RequiresAuthentication() - http.post "/" (fun p -> + http.post "/" (fun _ -> runDeployment workDir http.Request) - http.get "/deployments/" (fun p -> + http.get "/deployments/" (fun _ -> let status = http.Request.Query ?> "status" match status with | "active" -> getActiveReleases workDir @@ -92,4 +89,4 @@ type DeployAgentModule() as http = .AsJson result ) - http.get "/statistics/" (fun p -> getStatistics() |> http.Response.AsJson) + http.get "/statistics/" (fun _ -> getStatistics() |> http.Response.AsJson) diff --git a/src/app/Fake.Deploy/DeploymentHelper.fs b/src/app/Fake.Deploy/DeploymentHelper.fs index 871005d3420..3a8c992daf2 100644 --- a/src/app/Fake.Deploy/DeploymentHelper.fs +++ b/src/app/Fake.Deploy/DeploymentHelper.fs @@ -2,9 +2,7 @@ module Fake.DeploymentHelper open System -open System.Configuration open System.IO -open System.Net open Fake.FakeDeployAgentHelper /// Allows to specify a deployment version @@ -72,7 +70,7 @@ let unpack workDir isRollback packageBytes = package, scriptFile /// Runs a deployment script from the given package -let doDeployment packageName scriptFileName scriptArgs = +let doDeployment scriptFileName scriptArgs = try TargetHelper.reset() let workingDirectory = DirectoryName scriptFileName @@ -96,8 +94,8 @@ let doDeployment packageName scriptFileName scriptArgs = let runDeploymentFromPackageFile workDir packageFileName scriptArgs = try let packageBytes = ReadFileAsBytes packageFileName - let package, scriptFile = unpack workDir false packageBytes - doDeployment package.Name scriptFile scriptArgs + let _, scriptFile = unpack workDir false packageBytes + doDeployment scriptFile scriptArgs with e -> Failure { Messages = Seq.empty IsError = true @@ -113,10 +111,10 @@ let rollback workDir (app : string) (version : string) = IsError = true Exception = (Exception "Cannot rollback to currently active version") } else - let package, scriptFile = unpack workDir true (backupPackageFileName |> ReadFileAsBytes) - doDeployment package.Name scriptFile [||] + let _, scriptFile = unpack workDir true (backupPackageFileName |> ReadFileAsBytes) + doDeployment scriptFile [||] with - | :? FileNotFoundException as e -> + | :? FileNotFoundException -> let msg = sprintf "Failed to rollback to %s %s could not find package file or deployment script file ensure the version is within the backup directory and the deployment script is in the root directory of the *.nupkg file" From 7660ed14d952f9cc2cd3b64931593cf040a7af03 Mon Sep 17 00:00:00 2001 From: Vasily Kirichenko Date: Thu, 12 Feb 2015 11:16:17 +0300 Subject: [PATCH 2/2] Fake.Deploy uses fsi.exe instead of FCS remove a couple unused function arguments --- src/app/FAKE/Program.fs | 2 +- src/app/Fake.Deploy/DeploymentHelper.fs | 4 +--- src/app/FakeLib/FSIHelper.fs | 19 +++++++++---------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/app/FAKE/Program.fs b/src/app/FAKE/Program.fs index 01bb4e4e181..f00cf290afc 100644 --- a/src/app/FAKE/Program.fs +++ b/src/app/FAKE/Program.fs @@ -116,7 +116,7 @@ try //TODO if printDetails then printEnvironment cmdArgs args - if not (runBuildScriptWithFsiArgsAt "" printDetails fsiArgs envVars) then Environment.ExitCode <- 1 + if not (runBuildScriptWithFsiArgsAt printDetails fsiArgs envVars) then Environment.ExitCode <- 1 else if printDetails then log "Ready." () diff --git a/src/app/Fake.Deploy/DeploymentHelper.fs b/src/app/Fake.Deploy/DeploymentHelper.fs index 3a8c992daf2..ff596e40241 100644 --- a/src/app/Fake.Deploy/DeploymentHelper.fs +++ b/src/app/Fake.Deploy/DeploymentHelper.fs @@ -73,9 +73,7 @@ let unpack workDir isRollback packageBytes = let doDeployment scriptFileName scriptArgs = try TargetHelper.reset() - let workingDirectory = DirectoryName scriptFileName - let (result, messages) = - FSIHelper.executeBuildScriptWithArgsAndReturnMessages workingDirectory (FullName scriptFileName) scriptArgs + let (result, messages) = FSIHelper.executeFSIWithScriptArgsAndReturnMessages (FullName scriptFileName) scriptArgs if result then Success { Messages = messages IsError = false diff --git a/src/app/FakeLib/FSIHelper.fs b/src/app/FakeLib/FSIHelper.fs index b138f925feb..051a2c1cf3b 100644 --- a/src/app/FakeLib/FSIHelper.fs +++ b/src/app/FakeLib/FSIHelper.fs @@ -5,7 +5,6 @@ module Fake.FSIHelper open System open System.IO -open System.Linq open System.Diagnostics open System.Threading @@ -78,7 +77,7 @@ let executeFSIWithArgs workingDirectory script extraFsiArgs args = result = 0 /// Run the given build script with fsi.exe and allows for extra arguments to the script. Returns output. -let executeFSIWithScriptArgsAndReturnMessages workingDirectory script (scriptArgs: string[]) = +let executeFSIWithScriptArgsAndReturnMessages script (scriptArgs: string[]) = let (result, messages) = ExecProcessRedirected (fun si -> FsiStartInfo "" (FsiArgs([], script, scriptArgs |> List.ofArray)) [] si) @@ -89,7 +88,7 @@ let executeFSIWithScriptArgsAndReturnMessages workingDirectory script (scriptArg open Microsoft.FSharp.Compiler.Interactive.Shell /// Run the given FAKE script with fsi.exe at the given working directory. Provides full access to Fsi options and args. Redirect output and error messages. -let internal runFAKEScriptWithFsiArgsAndRedirectMessages workingDirectory printDetails (FsiArgs(fsiOptions, script, scriptArgs)) args onErrMsg onOutMsg = +let internal runFAKEScriptWithFsiArgsAndRedirectMessages printDetails (FsiArgs(fsiOptions, script, scriptArgs)) args onErrMsg onOutMsg = if printDetails then traceFAKE "Running Buildscript: %s" script // Add arguments to the Environment @@ -138,7 +137,7 @@ let internal runFAKEScriptWithFsiArgsAndRedirectMessages workingDirectory printD raise exn /// Run the given buildscript with fsi.exe and allows for extra arguments to the script. Returns output. -let executeBuildScriptWithArgsAndReturnMessages workingDirectory script (scriptArgs: string[]) = +let executeBuildScriptWithArgsAndReturnMessages script (scriptArgs: string[]) = let messages = ref [] let appendMessage isError msg = messages := { IsError = isError @@ -146,20 +145,20 @@ let executeBuildScriptWithArgsAndReturnMessages workingDirectory script (scriptA Timestamp = DateTimeOffset.UtcNow } :: !messages let result = runFAKEScriptWithFsiArgsAndRedirectMessages - workingDirectory true (FsiArgs([], script, scriptArgs |> List.ofArray)) [] + true (FsiArgs([], script, scriptArgs |> List.ofArray)) [] (appendMessage true) (appendMessage false) (result, !messages) /// Run the given buildscript with fsi.exe at the given working directory. Provides full access to Fsi options and args. -let runBuildScriptWithFsiArgsAt workingDirectory printDetails (FsiArgs(fsiOptions, script, scriptArgs)) args = +let runBuildScriptWithFsiArgsAt printDetails (FsiArgs(fsiOptions, script, scriptArgs)) args = runFAKEScriptWithFsiArgsAndRedirectMessages - workingDirectory printDetails (FsiArgs(fsiOptions, script, scriptArgs)) args + printDetails (FsiArgs(fsiOptions, script, scriptArgs)) args traceError (fun s-> traceFAKE "%s" s) /// Run the given buildscript with fsi.exe at the given working directory. -let runBuildScriptAt workingDirectory printDetails script extraFsiArgs args = - runBuildScriptWithFsiArgsAt workingDirectory printDetails (FsiArgs(extraFsiArgs, script, [])) args +let runBuildScriptAt printDetails script extraFsiArgs args = + runBuildScriptWithFsiArgsAt printDetails (FsiArgs(extraFsiArgs, script, [])) args /// Run the given buildscript with fsi.exe let runBuildScript printDetails script extraFsiArgs args = - runBuildScriptAt "" printDetails script extraFsiArgs args + runBuildScriptAt printDetails script extraFsiArgs args