Created
March 5, 2020 20:23
-
-
Save matthid/cadeeb74bc5e8f3ed6bd172e3f999eda to your computer and use it in GitHub Desktop.
FAKE Standard Input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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