From 6da330efb23c0ce4c8d9d1e8cf79a66c6c0032c3 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Thu, 19 May 2011 19:39:13 +0100 Subject: [PATCH] Dispose PowerShell pipeline after use. --- .../Project/Src/Scripting/PowerShellHost.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PowerShellHost.cs b/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PowerShellHost.cs index f92eda707c..b35f7786c3 100644 --- a/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PowerShellHost.cs +++ b/src/AddIns/Misc/PackageManagement/Project/Src/Scripting/PowerShellHost.cs @@ -63,8 +63,9 @@ namespace ICSharpCode.PackageManagement.Scripting try { CreateRunspace(); - Pipeline pipeline = CreatePipeline(command); - pipeline.Invoke(); + using (Pipeline pipeline = CreatePipeline(command)) { + pipeline.Invoke(); + } } catch (Exception ex) { consoleHost.ScriptingConsole.WriteLine(ex.Message, ScriptingStyle.Error); @@ -161,8 +162,9 @@ namespace ICSharpCode.PackageManagement.Scripting "$input | ForEach-Object {$__args += $_}; " + "& '" + fileName + "' $__args[0] $__args[1] $__args[2] $__args[3]" + "Remove-Variable __args -Scope 0"; - Pipeline pipeline = CreatePipeline(command); - pipeline.Invoke(input); + using (Pipeline pipeline = CreatePipeline(command)) { + pipeline.Invoke(input); + } } catch (Exception ex) { consoleHost.ScriptingConsole.WriteLine(ex.Message, ScriptingStyle.Error);