public void RemovePackage(PackageId packageId)
        {
            var packageInfo = ProductPackages.FirstOrDefault(x => x.Configuration.Id.IsSamePackage(packageId));

            if (packageInfo != null)
            {
                ProductPackages.Remove(packageInfo);
            }

            var allPackages = Packages.GetNodes(new PackageId[] {});
            var builder     = new PackageGraphBuilder();

            foreach (var packageNode in allPackages)
            {
                if (packageNode.Package.IsSamePackage(packageId))
                {
                    continue;
                }

                builder.Append(packageNode.Package,
                               packageNode.Dependencies.Where(x => !x.Package.IsSamePackage(packageId)).Select(p => p.Package));
            }

            Packages = builder.Build();
        }
        public IEnumerable <string> GetInstalledFiles(PackageId packageId, bool nonSharedFilesOnly)
        {
            var packageInfo = ProductPackages.FirstOrDefault(x => x.Configuration.Id.IsSamePackage(packageId));

            if (packageInfo == null)
            {
                return new string[] {}
            }
            ;

            if (!nonSharedFilesOnly)
            {
                return(packageInfo.Files);
            }

            return(packageInfo.Files.Where(
                       file => !ProductPackages.Any(x => x != packageInfo && x.Files.Contains(file))).ToList());
        }
        /// <summary>
        /// Returns package's installed files
        /// </summary>
        /// <param name="packageId">Package ID</param>
        /// <param name="nonSharedFilesOnly">When true, instructs function to return only the files which are unique for the package</param>
        /// <returns>Files list</returns>
        public IReadOnlyCollection <IPackageFile> GetInstalledFiles(PackageId packageId, bool nonSharedFilesOnly)
        {
            var packageInfo = ProductPackages.FirstOrDefault(x => x.Configuration.Id.IsSamePackage(packageId));

            if (packageInfo == null)
            {
                return(new List <PackageFileInfo>(new PackageFileInfo[] {}));
            }

            var files = !nonSharedFilesOnly
                ? packageInfo.Files
                : packageInfo.Files.Where(file => !ProductPackages.Any(x => x != packageInfo && x.Files.Any(file.IsSameFile)))
                        .ToList();

            if (string.IsNullOrWhiteSpace(_productPath))
            {
                return(files);
            }

            return(files.Select(
                       x => Path.IsPathRooted(x.FileName) ? x : new PackageFileInfo(Path.Combine(_productPath, x.FileName)))
                   .ToList());
        }
 public IPackageConfiguration GetPackageConfiguration(PackageId packageId)
 {
     return(ProductPackages.FirstOrDefault(x => x.Configuration.Id.IsSamePackage(packageId))?.Configuration);
 }