Last active
August 29, 2015 14:27
-
-
Save nbevans/45dd66f147277a2ea3dd to your computer and use it in GitHub Desktop.
Temporary productivity workaround for Xamarin bug #31423
This file contains 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
open System.Diagnostics | |
open System.Text.RegularExpressions | |
// Pre-req: FSharp runtime | |
// Usage: run from command line using "fsi.exe kill-locked-handles.fsx" no quotes | |
// Hints & tips as follows: | |
// Prepare the script by editing line 11 with a search string that will be used by handle.exe | |
// Ensure handle.exe (from SysInternals) is in your PATH, or edit this script to use an absolute path, or ensure handle.exe is in same path as this script. | |
// Edit into your build script or pre-build event on your project so this script is run each time. | |
let psi = new ProcessStartInfo("handle.exe", @"-p devenv.exe singapore.mobile.android\bin\debug\", RedirectStandardOutput = true, UseShellExecute = false) | |
let proc = Process.Start(psi) | |
proc.WaitForExit(5000) |> ignore | |
let output = proc.StandardOutput.ReadToEnd() | |
let regex = new Regex(@"devenv.exe pid: (?<ProcessId>\d+) type: File (?<FileHandle>[0-9a-f]+): ", RegexOptions.ExplicitCapture ||| RegexOptions.IgnoreCase) | |
for m in regex.Matches(output) |> Seq.cast<Match> do | |
let processId, fileHandle = m.Groups.["ProcessId"].Value, m.Groups.["FileHandle"].Value | |
let psi = new ProcessStartInfo("handle.exe", sprintf "-p %s -c %s -y" processId fileHandle, UseShellExecute = false) | |
Process.Start(psi).WaitForExit(5000) |> ignore |
This file contains 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
pushd $(ProjectDir) | |
fsi kill-locked-handles.fsx | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment