From 78998fd064beee9c41c8604d395e9d2136e0100b Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Mon, 9 Jan 2017 01:19:55 -0800 Subject: [PATCH] mage GetChocolatey static --- Boxstarter.Chocolatey/invoke-chocolatey.ps1 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Boxstarter.Chocolatey/invoke-chocolatey.ps1 b/Boxstarter.Chocolatey/invoke-chocolatey.ps1 index 3cc7ad11..1198d89b 100644 --- a/Boxstarter.Chocolatey/invoke-chocolatey.ps1 +++ b/Boxstarter.Chocolatey/invoke-chocolatey.ps1 @@ -2,7 +2,8 @@ function Invoke-Chocolatey($chocoArgs) { Write-BoxstarterMessage "Current runtime is $($PSVersionTable.CLRVersion)" -Verbose $refs = @( "$($Boxstarter.BaseDir)/boxstarter.chocolatey/chocolatey/log4net.dll", - "$($Boxstarter.BaseDir)/boxstarter.chocolatey/chocolatey/chocolatey.dll" + "$($Boxstarter.BaseDir)/boxstarter.chocolatey/chocolatey/chocolatey.dll", + "$($Boxstarter.BaseDir)/boxstarter.chocolatey/chocolatey/AlphaFS.dll" ) $refs | % { Write-BoxstarterMessage "Adding types from $_" -Verbose @@ -32,12 +33,14 @@ namespace Boxstarter public class ChocolateyWrapper { - private GetChocolatey _choco; + private static GetChocolatey _choco; public ChocolateyWrapper(string boxstarterSetup, PSHostUserInterface ui, bool logDebug, string logPath, bool quiet) { - _choco = Lets.GetChocolatey(); - var psService = new PowershellService(new DotNetFileSystem(), boxstarterSetup); - _choco.RegisterContainerComponent(() => psService); + if (_choco == null) { + _choco = Lets.GetChocolatey(); + var psService = new PowershellService(new DotNetFileSystem(), boxstarterSetup); + _choco.RegisterContainerComponent(() => psService); + } _choco.SetCustomLogging(new PsLogger(ui, logDebug, logPath, quiet)); } @@ -242,7 +245,7 @@ namespace Boxstarter } Enter-BoxstarterLogable { - Write-BoxstarterMessage "calling choco now with $chocoArgs" -verbose + Write-BoxstarterMessage "calling choco now with $chocoArgs" -Verbose $cd = [System.IO.Directory]::GetCurrentDirectory() try { # Chocolatey.dll uses GetCurrentDirectory which is not quite right