public ISharedPackageRepository CreateSharedRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, IFileSystem configSettingsFileSystem) { PathResolverPassedToCreateSharedRepository = pathResolver; FileSystemPassedToCreateSharedRepository = fileSystem; ConfigSettingsFileSystemPassedToCreateSharedRepository = configSettingsFileSystem; return FakeSharedRepository; }
public static IPackageRepository GetLocalRepository(IPackagePathResolver pathResolver, IFileSystem nugetPackagesFileSystem) { IPackageRepository localRepository = new ChocolateyLocalPackageRepository(pathResolver, nugetPackagesFileSystem); localRepository.PackageSaveMode = PackageSaveModes.Nupkg; return localRepository; }
public ISharedPackageRepository CreateSharedRepository( IPackagePathResolver pathResolver, IFileSystem fileSystem, IFileSystem configSettingsFileSystem) { return new SharedPackageRepository(pathResolver, fileSystem, configSettingsFileSystem); }
public PackageManager( IPackageRepository sourceRepository, IPackagePathResolver pathResolver, IFileSystem fileSystem, ISharedPackageRepository localRepository) { if (sourceRepository == null) { throw new ArgumentNullException("sourceRepository"); } if (pathResolver == null) { throw new ArgumentNullException("pathResolver"); } if (fileSystem == null) { throw new ArgumentNullException("fileSystem"); } if (localRepository == null) { throw new ArgumentNullException("localRepository"); } SourceRepository = sourceRepository; DependencyResolver = new DependencyResolverFromRepo(sourceRepository); PathResolver = pathResolver; FileSystem = fileSystem; LocalRepository = localRepository; DependencyVersion = DependencyVersion.Lowest; CheckDowngrade = true; }
public SharpDevelopProjectManager(IPackageRepository sourceRepository, IPackagePathResolver pathResolver, IProjectSystem project, IPackageRepository localRepository) : base(sourceRepository, pathResolver, project, localRepository) { }
public Ps1ScaffolderLocator(IPowershellCommandInvoker commandInvoker, IPackageManager packageManager, IPackagePathResolver pathResolver, FileSystem.IFileSystem fileSystem, IScaffoldingConfigStore configStore) { _commandInvoker = commandInvoker; _packageManager = packageManager; _pathResolver = pathResolver ?? packageManager.PathResolver; _fileSystem = fileSystem; _configStore = configStore; }
public VsProjectManager( VsPackageManager packageManager, IPackagePathResolver pathResolver, IProjectSystem project, IPackageRepository localRepository) : base(packageManager, pathResolver, project, localRepository) { _packageManager = packageManager; }
public SharedPackageRepository(IPackagePathResolver resolver, IFileSystem fileSystem, IFileSystem configSettingsFileSystem) : base(resolver, fileSystem) { if (configSettingsFileSystem == null) { throw new ArgumentNullException("configSettingsFileSystem"); } _packageReferenceFile = new PackageReferenceFile(configSettingsFileSystem, Constants.PackageReferenceFile); }
public ServerPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem) { if (pathResolver == null) { throw new ArgumentNullException("pathResolver"); } if (fileSystem == null) { throw new ArgumentNullException("fileSystem"); } _fileSystem = fileSystem; _pathResolver = pathResolver; }
public SharpDevelopPackageManager( IPackageRepository sourceRepository, IProjectSystem projectSystem, IFileSystem fileSystem, ISharedPackageRepository localRepository, IPackagePathResolver pathResolver) : base( sourceRepository, pathResolver, fileSystem, localRepository) { this.projectSystem = projectSystem; CreateProjectManager(); }
public PackageFolder( string physicalPath, bool ignoreFailure, Reports reports) { // We need to help restore operation to ensure case-sensitivity here // Turn on the flag to get package ids in accurate casing _repository = new PackageRepository(physicalPath, caseSensitivePackagesName: true); _fileSystem = new PhysicalFileSystem(physicalPath); _pathResolver = new DefaultPackagePathResolver(_fileSystem); _reports = reports; Source = physicalPath; _ignored = false; _ignoreFailure = ignoreFailure; }
public LocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, bool enableCaching) { if (pathResolver == null) { throw new ArgumentNullException("pathResolver"); } if (fileSystem == null) { throw new ArgumentNullException("fileSystem"); } FileSystem = fileSystem; PathResolver = pathResolver; _enableCaching = enableCaching; }
public ServerPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, Func<string, bool, bool> getSetting = null) { if (pathResolver == null) { throw new ArgumentNullException("pathResolver"); } if (fileSystem == null) { throw new ArgumentNullException("fileSystem"); } _fileSystem = fileSystem; _pathResolver = pathResolver; _getSetting = getSetting ?? GetBooleanAppSetting; }
public ServerPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, Func <string, bool, bool> getSetting = null) { if (pathResolver == null) { throw new ArgumentNullException("pathResolver"); } if (fileSystem == null) { throw new ArgumentNullException("fileSystem"); } _fileSystem = fileSystem; _pathResolver = pathResolver; _getSetting = getSetting ?? GetBooleanAppSetting; }
public LocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, bool enableCaching) { this._packageCache = new ConcurrentDictionary <string, PackageCacheEntry>(StringComparer.OrdinalIgnoreCase); this._packagePathLookup = new ConcurrentDictionary <PackageName, string>(); if (pathResolver == null) { throw new ArgumentNullException("pathResolver"); } if (fileSystem == null) { throw new ArgumentNullException("fileSystem"); } this.FileSystem = fileSystem; this.PathResolver = pathResolver; this._enableCaching = enableCaching; }
public ServerPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem) { if (pathResolver == null) { throw new ArgumentNullException("pathResolver"); } if (fileSystem == null) { throw new ArgumentNullException("fileSystem"); } _fileSystem = fileSystem; _pathResolver = pathResolver; Logger = fileSystem.Logger; }
public static LockFileLibrary CreateLockFileLibrary(LockFileLibrary previousLibrary, IPackagePathResolver resolver, IPackage package, string correctedPackageName = null) { var lockFileLib = new LockFileLibrary(); // package.Id is read from nuspec and it might be in wrong casing. // correctedPackageName should be the package name used by dependency graph and // it has the correct casing that runtime needs during dependency resolution. lockFileLib.Name = correctedPackageName ?? package.Id; lockFileLib.Version = package.Version; lockFileLib.Sha512 = File.ReadAllText(resolver.GetHashPath(package.Id, package.Version)); // If the shas are equal then do nothing if (previousLibrary?.Sha512 == lockFileLib.Sha512) { lockFileLib.Files = previousLibrary.Files; lockFileLib.IsServiceable = previousLibrary.IsServiceable; } else { lockFileLib.Files = package.GetFiles().Select(p => p.Path).ToList(); var installPath = resolver.GetInstallPath(package.Id, package.Version); foreach (var filePath in lockFileLib.Files) { if (!string.Equals(Path.GetExtension(filePath), ".dll", StringComparison.OrdinalIgnoreCase)) { continue; } var assemblyPath = Path.Combine(installPath, filePath); try { if (IsAssemblyServiceable(assemblyPath)) { lockFileLib.IsServiceable = true; break; } } catch { // Just move on to the next file } } } return lockFileLib; }
public LocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, IReport report, bool enableCaching) { if (pathResolver == null) { throw new ArgumentNullException(nameof(pathResolver)); } if (fileSystem == null) { throw new ArgumentNullException(nameof(fileSystem)); } FileSystem = fileSystem; PathResolver = pathResolver; _enableCaching = enableCaching; _report = report; }
public static JObject CreatePackage(IPackage version, string repoRoot, IPackagePathResolver pathResolver) { var value = new JObject(); AddProp(value, Properties.Type, new JArray( Types.PackageIdentity.ToString(), Types.PackageDescription.ToString(), Types.PackageDependencies.ToString(), Types.PackageLicensing.ToString())); AddProp(value, Properties.PackageId, version.Id); AddProp(value, Properties.Version, version.Version.ToString()); AddProp(value, Properties.Summary, version.Summary); AddProp(value, Properties.Description, version.Description); AddProp(value, Properties.Authors, String.Join(", ", version.Authors)); AddProp(value, Properties.Owners, String.Join(", ", version.Owners)); AddProp(value, Properties.IconUrl, version.IconUrl); AddProp(value, Properties.LicenseUrl, version.LicenseUrl); AddProp(value, Properties.ProjectUrl, version.ProjectUrl); AddProp(value, Properties.Tags, version.Tags == null ? null : version.Tags.Split(' ')); AddProp(value, Properties.DownloadCount, version.DownloadCount); AddProp(value, Properties.Published, version.Published.HasValue ? version.Published.Value.ToString("O", CultureInfo.InvariantCulture) : null); AddProp(value, Properties.RequireLicenseAcceptance, version.RequireLicenseAcceptance); AddProp(value, Properties.DependencyGroups, version.DependencySets.Select(set => CreateDependencyGroup(set))); if (version.MinClientVersion != null) { AddProp(value, Properties.MinimumClientVersion, version.MinClientVersion.ToString()); } var dsPackage = version as DataServicePackage; if (dsPackage != null) { AddProp(value, Properties.PackageContent, dsPackage.DownloadUrl); } else if (pathResolver != null) { AddProp( value, Properties.PackageContent, Path.Combine(repoRoot, pathResolver.GetPackageFileName(version))); } return(value); }
private void EnsureMainAssemblyLoadedInAppDomain(IPackagePathResolver pathResolver, IPackage package, PackageMetadata packageInfo, Guid correlationId) { var mainAssemblyFileName = $"{PackageMainAssemblySubFolderPath}{packageInfo.PackageKey}{DefaultAssemblyExtensionLowerCase}"; var mainAssemblyPackageFile = package .GetLibFiles() .FirstOrDefault(libFile => libFile.Path.Equals(mainAssemblyFileName, StringComparison.InvariantCultureIgnoreCase)); if (mainAssemblyPackageFile == null) { this.LogPackageOperation(packageInfo.PackageKey, package.Version, $"No assembly {mainAssemblyFileName} found in {package.GetFullName()}", correlationId); return; } var mainAssemblyFullPath = Path.Combine(pathResolver.GetInstallPath(package), mainAssemblyPackageFile.Path); this.LogPackageOperation(packageInfo.PackageKey, package.Version, $"AppDomain.LoadAssembly:'{mainAssemblyFullPath}'", correlationId); AppDomain.CurrentDomain.Load(AssemblyName.GetAssemblyName(mainAssemblyFullPath)); }
public PackageManager(IPackageRepository sourceRepository, IPackagePathResolver pathResolver, IFileSystem fileSystem, IPackageRepository localRepository) { if (sourceRepository == null) { throw new ArgumentNullException("sourceRepository"); } if (pathResolver == null) { throw new ArgumentNullException("pathResolver"); } if (fileSystem == null) { throw new ArgumentNullException("fileSystem"); } if (localRepository == null) { throw new ArgumentNullException("localRepository"); } SourceRepository = sourceRepository; PathResolver = pathResolver; FileSystem = fileSystem; LocalRepository = localRepository; }
public void MarkPackageDirectoryForDeletion(IPackage package) { IFileSystem repositoryFileSystem = _repositoryFileSystemFactory(); IPackagePathResolver pathResolver = _packagePathResolverFactory(); string packageDirectoryName = pathResolver.GetPackageDirectory(package); try { if (repositoryFileSystem.DirectoryExists(packageDirectoryName)) { // NOTE: The repository should always be a PhysicalFileSystem, except during testing, so the // .deleteme marker file doesn't get checked into version control repositoryFileSystem.AddFile(packageDirectoryName + DeletionMarkerSuffix, Stream.Null); } } catch (Exception e) { repositoryFileSystem.Logger.Log(MessageLevel.Warning, String.Format(Resources.VsResources.Warning_FailedToMarkPackageDirectoryForDeletion, packageDirectoryName, e.Message)); } }
private string ResolvePackagePath(IPackagePathResolver defaultResolver, IEnumerable <IPackagePathResolver> cacheResolvers, PackageInfo packageInfo) { string expectedHash = packageInfo.LockFileLibrary.Sha512; foreach (var resolver in cacheResolvers) { var cacheHashFile = resolver.GetHashPath(packageInfo.Id, packageInfo.Version); // REVIEW: More efficient compare? if (File.Exists(cacheHashFile) && File.ReadAllText(cacheHashFile) == expectedHash) { return(resolver.GetInstallPath(packageInfo.Id, packageInfo.Version)); } } return(defaultResolver.GetInstallPath(packageInfo.Id, packageInfo.Version)); }
internal void InstallPackages(IPackageRepository localRepository, IFileSystem sharedRepositoryFileSystem, ISharedPackageRepository sharedPackageRepository, IPackageRepository sourceRepository, IPackageConstraintProvider constraintProvider, IPackagePathResolver pathResolver, IProjectSystem project) { var packageManager = new PackageManager(sourceRepository, pathResolver, sharedRepositoryFileSystem, sharedPackageRepository); var projectManager = new ProjectManager(packageManager, pathResolver, project, localRepository) { ConstraintProvider = constraintProvider }; // Fix for work item 2411: When updating packages, we did not add packages to the shared package repository. // Consequently, when querying the package reference repository, we would have package references with no backing package files in // the shared repository. This would cause the reference repository to skip the package assuming that the entry is invalid. projectManager.PackageReferenceAdded += (sender, eventArgs) => { PackageExtractor.InstallPackage(packageManager, eventArgs.Package); }; projectManager.Logger = project.Logger = this; bool allowPrerelease = Prerelease; var resolver = new ActionResolver() { AllowPrereleaseVersions = allowPrerelease }; var installPackageUtility = new InstallPackageUtility(resolver) { AllowPrereleaseVersions = allowPrerelease, Safe = Safe }; var operations = installPackageUtility.ResolveActionsForInstallPackage(Id.FirstOrDefault(), Version, new[] { projectManager }, false); var userOperationExecutor = new ActionExecutor(); userOperationExecutor.Execute(operations); }
private string ResolvePackagePath(IPackagePathResolver defaultResolver, IEnumerable <IPackagePathResolver> cacheResolvers, IPackage package) { var defaultHashPath = defaultResolver.GetHashPath(package.Id, package.Version); string expectedHash = null; if (File.Exists(defaultHashPath)) { expectedHash = File.ReadAllText(defaultHashPath); } else if (_globalSettings != null) { var library = new Library() { Name = package.Id, Version = package.Version }; _globalSettings.PackageHashes.TryGetValue(library, out expectedHash); } if (string.IsNullOrEmpty(expectedHash)) { return(defaultResolver.GetInstallPath(package.Id, package.Version)); } foreach (var resolver in cacheResolvers) { var cacheHashFile = resolver.GetHashPath(package.Id, package.Version); // REVIEW: More efficient compare? if (File.Exists(cacheHashFile) && File.ReadAllText(cacheHashFile) == expectedHash) { return(resolver.GetInstallPath(package.Id, package.Version)); } } return(defaultResolver.GetInstallPath(package.Id, package.Version)); }
private static string ResolvePackagePath(IPackagePathResolver defaultResolver, IEnumerable <IPackagePathResolver> cacheResolvers, IPackage package) { var defaultHashPath = defaultResolver.GetHashPath(package.Id, package.Version); foreach (var resolver in cacheResolvers) { var cacheHashFile = resolver.GetHashPath(package.Id, package.Version); // REVIEW: More efficient compare? if (File.Exists(defaultHashPath) && File.Exists(cacheHashFile) && File.ReadAllText(defaultHashPath) == File.ReadAllText(cacheHashFile)) { return(resolver.GetInstallPath(package.Id, package.Version)); } } return(defaultResolver.GetInstallPath(package.Id, package.Version)); }
internal void UpdatePackages(IPackageRepository localRepository, IPackageRepository sourceRepository, IPackageConstraintProvider constraintProvider, IPackagePathResolver pathResolver, IProjectSystem project) { var projectManager = new ProjectManager(sourceRepository, pathResolver, project, localRepository) { ConstraintProvider = constraintProvider }; if (Verbose) { projectManager.Logger = Console; } using (sourceRepository.StartOperation(RepositoryOperationNames.Update)) { UpdatePackages(localRepository, projectManager); } }
internal IEnumerable <PackageDependency> GetReferences(IPackageRepository localRepository, IFileSystem sharedRepositoryFileSystem, ISharedPackageRepository sharedPackageRepository, IPackageRepository sourceRepository, IPackageConstraintProvider constraintProvider, IPackagePathResolver pathResolver, IProjectSystem project) { var packageManager = new PackageManager(sourceRepository, pathResolver, sharedRepositoryFileSystem, sharedPackageRepository); var projectManager = new ProjectManager(sourceRepository, pathResolver, project, localRepository) { ConstraintProvider = constraintProvider }; // Fix for work item 2411: When updating packages, we did not add packages to the shared package repository. // Consequently, when querying the package reference repository, we would have package references with no backing package files in // the shared repository. This would cause the reference repository to skip the package assuming that the entry is invalid. projectManager.PackageReferenceAdded += (sender, eventArgs) => { PackageExtractor.InstallPackage(packageManager, eventArgs.Package); }; projectManager.Logger = project.Logger = new NugetUpdateTask.VerboseLogger(this); using (sourceRepository.StartOperation(RepositoryOperationNames.Update)) { foreach (var package in GetPackages(localRepository)) { if (localRepository.Exists(package.Id)) { if (projectManager.IsInstalled(package)) { Log(Level.Debug, "Found installed package {0} version {1}", package.Id, package.Version); yield return(new PackageDependency(package.Id, new VersionSpec(package.Version))); } } } } }
public ProjectManager(IPackageManager packageManager, IPackagePathResolver pathResolver, IProjectSystem project, IPackageRepository localRepository) { // !!! TODO: we should get rid of the parameter pathResolver. Use packageManager's path resolver // instead. if (pathResolver == null) { throw new ArgumentNullException("pathResolver"); } if (project == null) { throw new ArgumentNullException("project"); } if (localRepository == null) { throw new ArgumentNullException("localRepository"); } PackageManager = packageManager; Project = project; PathResolver = pathResolver; LocalRepository = localRepository; _packageReferenceRepository = LocalRepository as IPackageReferenceRepository; }
public ProjectManager(IPackageRepository sourceRepository, IPackagePathResolver pathResolver, IProjectSystem project, IPackageRepository localRepository) { if (sourceRepository == null) { throw new ArgumentNullException("sourceRepository"); } if (pathResolver == null) { throw new ArgumentNullException("pathResolver"); } if (project == null) { throw new ArgumentNullException("project"); } if (localRepository == null) { throw new ArgumentNullException("localRepository"); } SourceRepository = sourceRepository; Project = project; PathResolver = pathResolver; LocalRepository = localRepository; }
public FakeSharedPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem) { this.PackagePathResolverPassedToConstructor = pathResolver; this.FileSystemPassedToConstructor = fileSystem; }
public SharedPackageRepository(IPackagePathResolver resolver, IFileSystem fileSystem, IFileSystem configSettingsFileSystem) : this(resolver, fileSystem, fileSystem, configSettingsFileSystem) { }
public LocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem) : this(pathResolver, fileSystem, enableCaching: true) { }
public MockSharedRepository(IPackagePathResolver resolver, IFileSystem fileSystem) : base(resolver, fileSystem, new MockFileSystem()) { }
/// <summary> /// The standard constructor. We'll just call the base constructor. /// </summary> /// <param name="sourceRepository"></param> /// <param name="pathResolver"></param> /// <param name="project"></param> /// <param name="localRepository"></param> public RockProjectManager(IPackageRepository sourceRepository, IPackagePathResolver pathResolver, IProjectSystem project, IPackageRepository localRepository) : base(sourceRepository, pathResolver, project, localRepository) { }
ISharedPackageRepository CreateSharedRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem) { return packageRepositoryFactory.CreateSharedRepository(pathResolver, fileSystem); }
public LucenePackageRepository(IPackagePathResolver packageResolver, IFileSystem fileSystem) : base(packageResolver, fileSystem) { }
internal void UpdatePackages(IPackageRepository localRepository, IFileSystem sharedRepositoryFileSystem, ISharedPackageRepository sharedPackageRepository, IPackageRepository sourceRepository, IPackageConstraintProvider constraintProvider, IPackagePathResolver pathResolver, IProjectSystem project) { var packageManager = new PackageManager(sourceRepository, pathResolver, sharedRepositoryFileSystem, sharedPackageRepository); var projectManager = new ProjectManager(packageManager, pathResolver, project, localRepository) { ConstraintProvider = constraintProvider }; // Fix for work item 2411: When updating packages, we did not add packages to the shared package repository. // Consequently, when querying the package reference repository, we would have package references with no backing package files in // the shared repository. This would cause the reference repository to skip the package assuming that the entry is invalid. projectManager.PackageReferenceAdded += (sender, eventArgs) => { PackageExtractor.InstallPackage(packageManager, eventArgs.Package); }; projectManager.Logger = project.Logger = this; foreach (var package in GetPackages(localRepository)) { if (localRepository.Exists(package.Id)) { using (sourceRepository.StartOperation(RepositoryOperationNames.Update, package.Id, mainPackageVersion: null)) { try { // If the user explicitly allows prerelease or if the package being updated is prerelease we'll include prerelease versions in our list of packages // being considered for an update. bool allowPrerelease = Prerelease || !package.IsReleaseVersion(); var resolver = new ActionResolver() { AllowPrereleaseVersions = allowPrerelease }; var updateUtility = new UpdateUtility(resolver) { AllowPrereleaseVersions = allowPrerelease, Safe = Safe }; var operations = updateUtility.ResolveActionsForUpdate(package.Id, null, new[] { projectManager }, false); var userOperationExecutor = new ActionExecutor(); userOperationExecutor.Execute(operations); } catch (InvalidOperationException e) { if (Console.Verbosity == NuGet.Verbosity.Detailed) { Console.WriteWarning(e.ToString()); } else { Console.WriteWarning(e.Message); } } } } } }
public UnzippedPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem) { FileSystem = fileSystem; PathResolver = pathResolver; }
public ISharedPackageRepository CreateSharedRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, IFileSystem configSettingsFileSystem) { return(factory.CreateSharedRepository(pathResolver, fileSystem, configSettingsFileSystem)); }
public ChocolateyLocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem) : base(pathResolver, fileSystem) { }
public PackageManager(IPackageRepository sourceRepository, IPackagePathResolver pathResolver, IFileSystem fileSystem) : this(sourceRepository, pathResolver, fileSystem, new LocalPackageRepository(pathResolver, fileSystem)) { }
public PackageDependencyProvider(string packagesPath) { _packagesPath = packagesPath; _cacheResolvers = GetCacheResolvers(); _packagePathResolver = new DefaultPackagePathResolver(packagesPath); }
public ISharedPackageRepository CreateSharedRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, IFileSystem configSettingsFileSystem) { throw new NotImplementedException(); }
private string ResolvePackagePath(IPackagePathResolver defaultResolver, IEnumerable<IPackagePathResolver> cacheResolvers, PackageInfo packageInfo) { string expectedHash = packageInfo.LockFileLibrary.Sha; foreach (var resolver in cacheResolvers) { var cacheHashFile = resolver.GetHashPath(packageInfo.Id, packageInfo.Version); // REVIEW: More efficient compare? if (File.Exists(cacheHashFile) && File.ReadAllText(cacheHashFile) == expectedHash) { return resolver.GetInstallPath(packageInfo.Id, packageInfo.Version); } } return defaultResolver.GetInstallPath(packageInfo.Id, packageInfo.Version); }
public PackageManager(IPackageRepository sourceRepository, IPackagePathResolver pathResolver, IFileSystem fileSystem) : this(sourceRepository, pathResolver, fileSystem, new SharedPackageRepository(pathResolver, fileSystem, fileSystem)) { }
public static IPackageManager GetPackageManager(ChocolateyConfiguration configuration, ILogger nugetLogger, IPackageDownloader packageDownloader, Action <PackageOperationEventArgs> installSuccessAction, Action <PackageOperationEventArgs> uninstallSuccessAction, bool addUninstallHandler) { IFileSystem nugetPackagesFileSystem = GetNuGetFileSystem(configuration, nugetLogger); IPackagePathResolver pathResolver = GetPathResolver(configuration, nugetPackagesFileSystem); var packageManager = new PackageManager(GetRemoteRepository(configuration, nugetLogger, packageDownloader), pathResolver, nugetPackagesFileSystem, GetLocalRepository(pathResolver, nugetPackagesFileSystem, nugetLogger)) { DependencyVersion = DependencyVersion.Highest, Logger = nugetLogger, }; //NOTE DO NOT EVER use this method - packageManager.PackageInstalling += (s, e) => packageManager.PackageInstalled += (s, e) => { var pkg = e.Package; "chocolatey".Log().Info(ChocolateyLoggers.Important, "{0}{1} v{2}{3}{4}{5}".format_with( System.Environment.NewLine, pkg.Id, pkg.Version.to_string(), configuration.Force ? " (forced)" : string.Empty, pkg.IsApproved ? " [Approved]" : string.Empty, pkg.PackageTestResultStatus == "Failing" && pkg.IsDownloadCacheAvailable ? " - Likely broken for FOSS users (due to download location changes)" : pkg.PackageTestResultStatus == "Failing" ? " - Possibly broken" : string.Empty )); if (installSuccessAction != null) { installSuccessAction.Invoke(e); } }; if (addUninstallHandler) { // NOTE DO NOT EVER use this method, or endless loop - packageManager.PackageUninstalling += (s, e) => packageManager.PackageUninstalled += (s, e) => { IPackage pkg = packageManager.LocalRepository.FindPackage(e.Package.Id, e.Package.Version); if (pkg != null) { // install not actually removed, let's clean it up. This is a bug with nuget, where it reports it removed some package and did NOTHING // this is what happens when you are switching from AllowMultiple to just one and back var chocoPathResolver = packageManager.PathResolver as ChocolateyPackagePathResolver; if (chocoPathResolver != null) { chocoPathResolver.UseSideBySidePaths = !chocoPathResolver.UseSideBySidePaths; // an unfound package folder can cause an endless loop. // look for it and ignore it if doesn't line up with versioning if (nugetPackagesFileSystem.DirectoryExists(chocoPathResolver.GetInstallPath(pkg))) { //todo: This causes an issue with upgrades. // this causes this to be called again, which should then call the uninstallSuccessAction below packageManager.UninstallPackage(pkg, forceRemove: configuration.Force, removeDependencies: false); } chocoPathResolver.UseSideBySidePaths = configuration.AllowMultipleVersions; } } else { if (uninstallSuccessAction != null) { uninstallSuccessAction.Invoke(e); } } }; } return(packageManager); }
public BetterThanLocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, MSBuildProjectSystem projectSystem) : base(pathResolver, fileSystem) { _projectSystem = projectSystem; }
public LocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem) : this(pathResolver, fileSystem, enableCaching : true) { }
public PackageAssemblyReferencePathResolver(IPackagePathResolver pathResolver) { _pathResolver = pathResolver ?? throw new ArgumentNullException(nameof(pathResolver)); }
public SharedPackageRepository(IPackagePathResolver resolver, IFileSystem fileSystem) : base(resolver, fileSystem) { }
internal void UpdatePackages(IPackageRepository localRepository, IPackageRepository sourceRepository, IPackageConstraintProvider constraintProvider, IPackagePathResolver pathResolver, IProjectSystem project) { var projectManager = new ProjectManager(sourceRepository, pathResolver, project, localRepository) { ConstraintProvider = constraintProvider }; if (Verbose) { projectManager.Logger = Console; } foreach (var package in GetPackages(localRepository)) { if (localRepository.Exists(package.Id)) { try { // If the user explicitly allows prerelease or if the package being updated is prerelease we'll include prerelease versions in our list of packages // being considered for an update. bool allowPrerelease = Prerelease || !package.IsReleaseVersion(); if (Safe) { IVersionSpec safeRange = VersionUtility.GetSafeRange(package.Version); projectManager.UpdatePackageReference(package.Id, safeRange, updateDependencies: true, allowPrereleaseVersions: allowPrerelease); } else { projectManager.UpdatePackageReference(package.Id, version: null, updateDependencies: true, allowPrereleaseVersions: allowPrerelease); } } catch (InvalidOperationException e) { Console.WriteWarning(e.Message); } } } }
public ChocolateyLocalPackageRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, bool enableCaching) : base(pathResolver, fileSystem, enableCaching) { }
public IPackageRepository get_local_repository(IPackagePathResolver pathResolver, NuGet.IFileSystem nugetPackagesFileSystem) { this.Log().Debug(() => "Setting up local repository at '{0}'".format_with(nugetPackagesFileSystem.Root)); IPackageRepository localRepository = new LocalPackageRepository(pathResolver, nugetPackagesFileSystem); localRepository.PackageSaveMode = PackageSaveModes.Nupkg | PackageSaveModes.Nuspec; return localRepository; }