Beispiel #1
0
        static UserRepository()
        {
            if (!Directory.Exists(UserSettings.UserRepositoryPath))
                Directory.CreateDirectory(UserSettings.UserRepositoryPath);

            Current = new FolderRepository(UserSettings.UserRepositoryPath);
        }
        protected void given_folder_repository_with_module(string packageName)
        {
            FileSystem = LocalFileSystem.Instance;
            RepositoryPath = FileSystem.CreateTempDirectory();
            Packager.NewWithDescriptor(
                RepositoryPath.GetFile(packageName + "-1.0.0.wrap"), 
                packageName,
                "1.0.0",
                "depends: nhibernate-core = 2.1"
                );

            Repository = new FolderRepository(RepositoryPath);
        }
        protected override void GetMetadata(string path, string repository, out PackageProject project, out IList<MetadataEntry> metadata, out ILookup<ContentType, string> contents)
        {
            var assemblyExporter = new DefaultAssemblyExporter();
            var packageInfo = new FolderRepository(LocalFileSystem.Instance.GetDirectory(path)).PackagesByName.Single().Single();
            var package = packageInfo.Load();
            var descriptor = package.Descriptor;

            var exports = assemblyExporter
                .Items<Exports.IAssembly>(package, ExecutionEnvironment.Any)
                .SelectMany(group => group)
                .GroupBy(assembly => new { assembly.Profile, assembly.Platform });

            project =
                new PackageProject
                    {
                        Name = descriptor.Name,
                        Repository = repository,
                        Version =
                            new PackageVersion
                                {
                                    Name = descriptor.Version.ToString(),
                                    Compilations = exports
                                        .Select(group =>
                                                new PackageCompilation
                                                    {
                                                        Mode = "Release",
                                                        Platform = group.Key.Profile + "-" + group.Key.Platform,
                                                        ImageFiles = group
                                                            .Select(assembly =>
                                                                new PackageImageFile
                                                                    {
                                                                        Name = GetAssemblyPath(assembly.File.Path, path)
                                                                    }).ToArray(),
                                                    }).ToArray(),
                                },
                    };

            using (var zip = new ZipFile(GetFilePath(path)))
                contents = zip.EntryFileNames.ToLookup(GetContentType);

            metadata = new List<MetadataEntry>();
        }
Beispiel #4
0
        ICommandOutput SetupEnvironmentForAdd()
        {
            var directory = HostEnvironment.CurrentDirectory;

            var fromDirectory = string.IsNullOrEmpty(From) ? null : FileSystem.GetDirectory(From);
            if (fromDirectory != null && fromDirectory.Exists)
            {
                if (SysPath.GetExtension(Name).EqualsNoCase(".wrap") &&
                    SysPath.IsPathRooted(Name) &&
                    FileSystem.GetDirectory(SysPath.GetDirectoryName(Name)) != fromDirectory)
                {
                    return new Error("You provided both -From and -Name, but -Name is a path. Try removing the -From parameter.");
                }
                directory = fromDirectory;
                _userSpecifiedRepository = new FolderRepository(directory, FolderRepositoryOptions.Default);
            }

            if (SysPath.GetExtension(Name).EqualsNoCase(".wrap") && directory.GetFile(SysPath.GetFileName(Name)).Exists)
            {
                var originalName = Name;
                Name = PackageNameUtility.GetName(SysPath.GetFileNameWithoutExtension(Name));
                Version = PackageNameUtility.GetVersion(SysPath.GetFileNameWithoutExtension(originalName)).ToString();

                return new Warning("The requested package contained '.wrap' in the name. Assuming you pointed to a file name and meant a package named '{0}' with version qualifier '{1}'.",
                                   Name,
                                   Version);
            }
            return null;
        }
Beispiel #5
0
        IEnumerable<ICommandOutput> CopyOpenWrap(PackageDescriptor projectDescriptor, IDirectory projectDirectory)
        {
            var packageManager = ServiceLocator.GetService<IPackageManager>();

            var repositoryOptions = FolderRepositoryOptions.AnchoringEnabled;
            if (projectDescriptor.UseSymLinks)
                repositoryOptions |= FolderRepositoryOptions.UseSymLinks;
            if (projectDescriptor.StorePackages)
                repositoryOptions |= FolderRepositoryOptions.PersistPackages;
            var projectRepository = new FolderRepository(projectDirectory.GetDirectory("wraps"), repositoryOptions)
            {
                Name = "Project repository"
            };
            packageManager.AddProjectPackage(PackageRequest.Any("openwrap"),
                                             new[] { Environment.SystemRepository },
                                             projectDescriptor,
                                             projectRepository,
                                             PackageAddOptions.Default | PackageAddOptions.Anchor | PackageAddOptions.Content).ToList();

            yield return new Info("Project repository initialized.");
        }
        public void Initialize()
        {
            FileSystem = LocalFileSystem.Instance;
            SystemRepositoryDirectory = SystemRepositoryDirectory ?? FileSystem.GetDirectory(DefaultInstallationPaths.SystemRepositoryDirectory);
            var descriptors = new PackageDescriptorReader().ReadAll(CurrentDirectory);
            if (descriptors.ContainsKey(string.Empty))
            {
                DescriptorFile = descriptors[string.Empty].File;
                Descriptor = descriptors[string.Empty].Value;
            }

            ScopedDescriptors = descriptors;
            TryInitializeProjectRepository();

            CurrentDirectoryRepository = new CurrentDirectoryRepository();

            SystemRepository = new FolderRepository(SystemRepositoryDirectory)
            {
                    Name = "System repository"
            };

            ConfigurationDirectory = FileSystem.GetDirectory(DefaultInstallationPaths.ConfigurationDirectory);

            RemoteRepositories = new RemoteRepositoryBuilder(FileSystem, Services.ServiceLocator.GetService<IConfigurationManager>()).GetConfiguredPackageRepositories().ToList();
            ExecutionEnvironment = new ExecutionEnvironment
            {
                    Platform = IntPtr.Size == 4 ? "x86" : "x64",
                    Profile = Environment.Version.Major >= 4 ? "net40" : "net35"
            };
        }
        IEnumerable<ICommandOutput> CopyOpenWrap(IDirectory projectDirectory)
        {
            var packageManager = Services.Services.GetService<IPackageResolver>();
            var initialDescriptor = new PackageDescriptor
            {
                Name = "openwrap",
                Dependencies =
                            {
                                    new PackageDependency
                                    {
                                            Name = "OpenWrap",
                                            VersionVertices = { new AnyVersionVertex() }
                                    }
                            }
            };

            DependencyResolutionResult openwrapPackage = packageManager.TryResolveDependencies(initialDescriptor, new[] { Environment.SystemRepository });
            var folderRepository = new FolderRepository(projectDirectory.GetDirectory("wraps"))
            {
                EnableAnchoring = true,
                Name = "Project repository"
            };
            foreach (ICommandOutput msg in packageManager.CopyPackagesToRepositories(
                    openwrapPackage,
                    Environment.SystemRepository,
                    folderRepository))
                yield return msg;
            folderRepository.Refresh();

            folderRepository.VerifyAnchors(new[] { folderRepository.PackagesByName["openwrap"].First() });
        }
 void EnsureWrapRepositoryIsInitialized()
 {
     if (PackageRepository != null) return;
     PackageRepository = new FolderRepository(WrapsDirectoryPath);
 }
        void TryInitializeProjectRepository()
        {
            if (Descriptor == null || DescriptorFile == null)
                return;
            if (Descriptor.UseProjectRepository)
            {
                var projectRepositoryDirectory = DescriptorFile.Parent.FindProjectRepositoryDirectory();

                if (projectRepositoryDirectory != null)
                    ProjectRepository = new FolderRepository(projectRepositoryDirectory)
                    {
                            Name = "Project repository",
                            EnableAnchoring=true
                    };
            }
        }
Beispiel #10
0
 public PackageStorageWithSource(FolderRepository parent, IDirectory packagesDirectory, IDirectory rootCacheDirectory) : base(parent, packagesDirectory, rootCacheDirectory)
 {
 }
Beispiel #11
0
 public PackageStorage(FolderRepository parent, IDirectory packagesDirectory, IDirectory rootCacheDirectory)
 {
     _parent             = parent;
     PackagesDirectory   = packagesDirectory;
     _rootCacheDirectory = rootCacheDirectory;
 }
        public void Initialize()
        {
            FileSystem = LocalFileSystem.Instance;
            SystemRepositoryDirectory = SystemRepositoryDirectory ?? FileSystem.GetDirectory(DefaultInstallationPaths.SystemRepositoryDirectory);

            TryInitializeProject();

            CurrentDirectoryRepository = new CurrentDirectoryRepository();

            SystemRepository = new FolderRepository(SystemRepositoryDirectory)
            {
                Name = "System repository"
            };

            ConfigurationDirectory = FileSystem.GetDirectory(DefaultInstallationPaths.ConfigurationDirectory);

            ExecutionEnvironment = new ExecutionEnvironment
            {
                Platform = IntPtr.Size == 4 ? "x86" : "x64",
                Profile = Environment.Version.Major >= 4 ? "net40" : "net35"
            };
        }
 protected void given_folder_repository(FolderRepositoryOptions options)
 {
     repository = new FolderRepository(repository_directory, options);
 }
 void EnsureWrapRepositoryIsInitialized()
 {
     if (PackageRepository != null)
     {
         Log.LogMessage(MessageImportance.Low, "No project repository found.");
         return;
     }
     PackageRepository = new FolderRepository(WrapsDirectoryPath);
 }
Beispiel #15
0
        IEnumerable<ICommandOutput> CopyOpenWrap(PackageDescriptor projectDescriptor, IDirectory projectDirectory)
        {
            var packageManager = Services.Services.GetService<IPackageManager>();

            var projectRepository = new FolderRepository(projectDirectory.GetDirectory("wraps"))
            {
                    EnableAnchoring = true,
                    Name = "Project repository"
            };
            packageManager.AddProjectPackage(PackageRequest.Any("openwrap"),
                                             new[] { Environment.SystemRepository },
                                             projectDescriptor,
                                             projectRepository,
                                             PackageAddOptions.Default | PackageAddOptions.Anchor | PackageAddOptions.Content).ToList();
            yield return new GenericMessage("Project repository initialized.");
        }
        void TryInitializeProjectRepository()
        {
            if (Descriptor == null || DescriptorFile == null)
                return;
            if (Descriptor.UseProjectRepository)
            {
                var projectRepositoryDirectory = DescriptorFile.Parent.FindProjectRepositoryDirectory();

                if (projectRepositoryDirectory != null)
                {
                    var repositoryOptions = FolderRepositoryOptions.AnchoringEnabled;
                    if (Descriptor.UseSymLinks)
                        repositoryOptions |= FolderRepositoryOptions.UseSymLinks;
                    ProjectRepository = new FolderRepository(projectRepositoryDirectory, repositoryOptions)
                    {
                            Name = "Project repository"
                    };
                }
            }
        }
        public void Initialize()
        {
            FileSystem = LocalFileSystem.Instance;
            Descriptor = CurrentDirectory
                .AncestorsAndSelf()
                .SelectMany(x => x.Files("*.wrapdesc"))
                .Select(x=>new WrapDescriptorParser().ParseFile(x))
                .FirstOrDefault();

            var projectRepositoryDirectory = Descriptor == null
                ? null
                : Descriptor.File.Parent
                    .AncestorsAndSelf()
                    .SelectMany(x => x.Directories("wraps"))
                    .Where(x => x != null)
                    .FirstOrDefault();

            if (projectRepositoryDirectory != null)
                ProjectRepository = new FolderRepository(projectRepositoryDirectory, true)
                {
                    Name = "Project repository"
                };

            CurrentDirectoryRepository = new CurrentDirectoryRepository();

            SystemRepository = new FolderRepository(FileSystem.GetDirectory(InstallationPaths.UserRepositoryPath), false)
            {
                Name="System repository"
            };

            ConfigurationDirectory = FileSystem.GetDirectory(InstallationPaths.ConfigurationDirectory);

            RemoteRepositories = WrapServices.GetService<IConfigurationManager>().LoadRemoteRepositories()
                .Select(x => new HttpRepository(FileSystem, new HttpRepositoryNavigator(x.Value.Href)))
                .Cast<IPackageRepository>()
                .ToList();

            ExecutionEnvironment = new ExecutionEnvironment
            {
                Platform = IntPtr.Size == 4 ? "x86" : "x64",
                Profile = "net35"
            };
        }