private void InstallPackageLocally(string packageId, string workDirectory) { var install = new InstallCommand(RepositoryFactory, SourceProvider); install.Arguments.Add(packageId); install.OutputDirectory = workDirectory; install.Console = Console; foreach (string source in Sources) { install.Source.Add(source); } if (!string.IsNullOrEmpty(Version)) { install.Version = Version; } install.ExecuteCommand(); }
void RetrievePackage(Package package) { var command = new InstallCommand(_repositoryFactory, _sourceProvider); command.Arguments.Add(package.Id); command.OutputDirectory = OutputDirectory; command.Console = base.Console; command.ExcludeVersion = ExcludeVersion; foreach (string source in Source) { command.Source.Add(source); } // Any version qualifies as a range (e.g. 1.0 --> 1.0 ≤ x) if (!string.IsNullOrEmpty(package.Version)) { SemanticVersion semanticVersion = null; if (SemanticVersion.TryParse(package.Version, out semanticVersion)) { foreach (string source in Source) { IPackageRepository repository = _repositoryFactory.CreateRepository(source); IPackage specificPackage = repository.FindPackage(package.Id, semanticVersion); if (specificPackage != null) { command.Version = semanticVersion.ToString(); break; } } } } command.ExecuteCommand(); }