Skip to content

Instantly share code, notes, and snippets.

@matthid
Created March 5, 2020 20:23
Show Gist options
  • Save matthid/cadeeb74bc5e8f3ed6bd172e3f999eda to your computer and use it in GitHub Desktop.
Save matthid/cadeeb74bc5e8f3ed6bd172e3f999eda to your computer and use it in GitHub Desktop.
FAKE Standard Input
#r "paket:
nuget Fake.Core.Target
nuget Fake.Core.Process
nuget Fake.IO.FileSystem prerelease
//"
#load "./.fake/test.fsx/intellisense.fsx"
#if !FAKE
#r "netstandard"
#r "Facades/netstandard" // https://github.com/ionide/ionide-vscode-fsharp/issues/839#issuecomment-396296095
#endif
open System
open System.IO
open Fake
open Fake.Core
open Fake.IO
Target.initEnvironment ()
let runToolWithInput cmd args workingDir inputStream =
let arguments = args |> String.split ' ' |> Arguments.OfArgs
Command.RawCommand (cmd,arguments)
|> CreateProcess.fromCommand
|> CreateProcess.withWorkingDirectory workingDir
|> CreateProcess.ensureExitCode
|> CreateProcess.withStandardInput (CreatePipe inputStream)
|> Proc.start
Target.create "ControlCmd" (fun _ ->
let streamRef = StreamRef.Empty
//Fake.IO.Shell.copyFile dbPath (serverPath + "/DevDatabase.sql")
let t = runToolWithInput "cmd.exe" "" __SOURCE_DIRECTORY__ streamRef
use writer = new StreamWriter(streamRef.Value)
writer.WriteLine("echo test123")
writer.Flush()
writer.WriteLine("exit")
writer.Flush()
Trace.trace "Startec CMD"
t.Wait()
)
open Fake.Core.TargetOperators
Target.runOrDefaultWithArguments "ControlCmd"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment