From 3c8ea927599c46f57ee11198b52a04d2b75992c0 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Fri, 5 Jun 2015 12:06:30 -0500 Subject: [PATCH] (GH-60) Fix: Pin errors on pkg folders w/versions If the package folder has a version on it, it is considered a side by side path, so the package manager may not be able to resolve the path to the locally installed nupkg. When it isn't found by regular means, attempt to find it by looking for it in side by side paths. If it is not found there either, go ahead and error. --- .../commands/ChocolateyPinCommand.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyPinCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyPinCommand.cs index 46518168ae..180d233c6f 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyPinCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyPinCommand.cs @@ -159,7 +159,17 @@ public void set_pin(IPackageManager packageManager, ChocolateyConfiguration conf IPackage installedPackage = packageManager.LocalRepository.FindPackage(config.PinCommand.Name, semanticVersion); if (installedPackage == null) { - throw new ApplicationException("Unable to find package named '{0}'{1} to pin. Please check to ensure it is installed.".format_with(config.PinCommand.Name, versionUnspecified ? "" : " (version '{0}')".format_with(config.Version))); + var pathResolver = packageManager.PathResolver as ChocolateyPackagePathResolver; + if (pathResolver != null) + { + pathResolver.UseSideBySidePaths = true; + installedPackage = packageManager.LocalRepository.FindPackage(config.PinCommand.Name, semanticVersion); + } + + if (installedPackage == null) + { + throw new ApplicationException("Unable to find package named '{0}'{1} to pin. Please check to ensure it is installed.".format_with(config.PinCommand.Name, versionUnspecified ? "" : " (version '{0}')".format_with(config.Version))); + } } var pkgInfo = _packageInfoService.get_package_information(installedPackage);