Skip to content

Instantly share code, notes, and snippets.

@TheAngryByrd
Last active September 18, 2016 01:52
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save TheAngryByrd/ca71ff3524e475b509fc to your computer and use it in GitHub Desktop.
Save TheAngryByrd/ca71ff3524e475b509fc to your computer and use it in GitHub Desktop.
Visual Studio Code mono debugging launch.json
//http://www.navision-blog.de/blog/2015/12/21/adding-background-tasks-to-suave-io-websites/
let startApp path =
let info = ProcessStartInfo(FileName = path)
let proc = new System.Diagnostics.Process(StartInfo = info)
start proc
proc
let rec runWebsite() =
let codeFolder = FullName "src"
use watcher = new FileSystemWatcher(codeFolder, "*.fs")
watcher.EnableRaisingEvents <- true
watcher.IncludeSubdirectories <- true
build()
copyBinaries()
let app = Path.Combine("bin","myapp","myapp.exe")
let proc = startApp app
let handleWatcherEvents = handleWatcherEvents proc.Id
watcher.Changed.Add(handleWatcherEvents)
watcher.Created.Add(handleWatcherEvents)
watcher.Renamed.Add(handleWatcherEvents)
proc.WaitForExit()
watcher.Dispose()
runWebsite()
and handleWatcherEvents id (e:IO.FileSystemEventArgs) =
tracefn "Rebuilding website...."
Process.GetProcessById(id).Kill()
Target "RunWebsite" (fun _ ->
async {
Threading.Thread.Sleep(15000)
Process.Start(sprintf "http://localhost:%d" 8080) |> ignore }
|> Async.Start
runWebsite()
)
{
"version": "0.1.0",
"configurations": [
{
"preLaunchTask": "Build",
"externalConsole": true,
"name": "Launch Server",
"type": "mono",
// Workspace relative or absolute path to the program.
"program": "${workspaceRoot}/bin/myapp/myapp.exe",
"stopOnEntry": true
},
{
"name": "Attach to Mono",
"request": "attach",
"type": "mono",
"address": "localhost",
"port": 55555
}
]
}
{
"version" : "0.1.0",
"windows": {
"command" : "build.cmd"
},
"osx": {
"command" : "./build.sh"
},
"linux": {
"command" : "./build.sh"
},
"isShellCommand" : true,
"echoCommand": true,
"showOutput" : "always",
"suppressTaskName": true,
"tasks": [ {
"taskName" : "Build",
"args" : ["CopyBinaries"],
"isBuildCommand" : true
},{
"taskName" : "RunTests",
"args" : ["RunTests"],
"isBuildCommand" : false,
"isTestCommand" : true
},{
"taskName" : "RunWebsite",
"args" : ["RunWebsite"],
"isBuildCommand" : false,
"isTestCommand" : false,
"isWatching": true
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment