Ejemplo n.º 1
0
        private static IEnumerable<IFile> Install(NuGetConfiguration configuration, DirectoryPath appDataPath)
        {
            var fileSystem = new FileSystem();
            var environment = new CakeEnvironment();
            var globber = new Globber(fileSystem, environment);

            var installer = new NuGetInstaller(fileSystem, globber);
            return installer.Install(configuration, appDataPath, true);
        }
Ejemplo n.º 2
0
        public static DocumentModel Download(
            DirectoryPath appDataPath, 
            NuGetConfiguration configuration, 
            out string version)
        {
            var fileSystem = new FileSystem();
            var environment = new CakeEnvironment();
            var globber = new Globber(fileSystem, environment);
            var installer = new NuGetInstaller(fileSystem, globber);

            var files = new Dictionary<string, IDocumentationMetadata>();
            foreach (var package in configuration.Packages)
            {
                var packageFiles = installer.Install(package, appDataPath);
                foreach (var packageFile in packageFiles)
                {
                    files.Add(packageFile.Path.FullPath, package.Metadata);
                }
            }

            // Find Cake.exe.
            version = "0.5.2"; // Default to this version if we could not find.
            var exe = files.Keys.FirstOrDefault(x => x.EndsWith("Cake.Core.dll"));
            if (exe != null)
            {
                var name = AssemblyName.GetAssemblyName(exe);
                if (name != null)
                {
                    version = string.Format("{0}.{1}.{2}",
                        name.Version.Major, name.Version.Minor,
                        name.Version.Build);
                }
            }

            // Build the model.
            return new DocumentModelBuilder()
                .BuildModel(files);
        }
Ejemplo n.º 3
0
        public IEnumerable<IFile> Install(NuGetConfiguration options, DirectoryPath root, bool installAddins)
        {
            var result = new List<FilePath>();
            foreach (var package in options.Packages)
            {
                var paths = new FilePathCollection(PathComparer.Default);

                // Install the package.
                var packagePath = Install(package, root);
                var packageDirectory = _fileSystem.GetDirectory(packagePath);

                if (package.Filters != null && package.Filters.Count > 0)
                {
                    // Get all files matching the filters.
                    foreach (var filter in package.Filters)
                    {
                        var pattern = string.Concat(packagePath.FullPath, "/", filter.TrimStart('/', '\\'));
                        paths.Add(_globber.GetFiles(pattern));
                    }
                }
                else
                {
                    // Do a recursive search in the package directory.
                    paths.Add(packageDirectory.
                        GetFiles("*", SearchScope.Recursive)
                        .Select(file => file.Path));
                }

                if (paths.Count > 0)
                {
                    result.AddRange(paths);
                }
            }

            return result.Select(path => _fileSystem.GetFile(path));
        }
Ejemplo n.º 4
0
 public static DocumentModel Download(DirectoryPath appDataPath, NuGetConfiguration configuration)
 {
     var files = Install(configuration, appDataPath);
     var builder = new DocumentModelBuilder();
     return builder.BuildModel(files.Select(x => x.Path.FullPath));
 }