示例#1
0
        public IEnumerable<IFile> Install(PackageDefinition package, DirectoryPath root)
        {
            var result = new List<FilePath>();
            var paths = new FilePathCollection(PathComparer.Default);

            // InstallPackage the package.
            var packagePath = InstallPackage(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));
        }
示例#2
0
        public DirectoryPath InstallPackage(PackageDefinition package, DirectoryPath root)
        {
            var packagePath = root.Combine("libs");
            if (!_fileSystem.Exist(packagePath))
            {
                _fileSystem.GetDirectory(packagePath).Create();
            }

            if (!_fileSystem.Exist(packagePath.Combine(package.PackageName)))
            {
                var packageManager = CreatePackageManager(packagePath);
                packageManager.InstallPackage(package.PackageName);
            }

            // Return the installation directory.
            return packagePath.Combine(package.PackageName);
        }
示例#3
0
        public DirectoryPath InstallPackage(PackageDefinition package, DirectoryPath root)
        {
            var packagePath = root.Combine("libs");

            if (!_fileSystem.Exist(packagePath))
            {
                _fileSystem.GetDirectory(packagePath).Create();
            }

            if (!_fileSystem.Exist(packagePath.Combine(package.PackageName)))
            {
                var packageManager = CreatePackageManager(packagePath);
                packageManager.InstallPackage(package.PackageName);
            }

            // Return the installation directory.
            return(packagePath.Combine(package.PackageName));
        }
示例#4
0
        private DirectoryPath InstallPackage(PackageDefinition package, DirectoryPath root)
        {
            var packagePath = root.Combine("libs");
            if (!_fileSystem.Exist(packagePath))
            {
                _fileSystem.GetDirectory(packagePath).Create();
            }
            var toolsPath = root.Combine("tools");
            var nugetToolPath = toolsPath.CombineWithFilePath("nuget.exe");
            if (!_fileSystem.Exist(toolsPath))
            {
                _fileSystem.GetDirectory(toolsPath).Create();
            }
            if (!_fileSystem.Exist(nugetToolPath))
            {
                DownloadNuget(nugetToolPath);
            }

            if (_fileSystem.Exist(packagePath.Combine(package.PackageName)))
            {
                return packagePath.Combine(package.PackageName);
            }

            var arguments = $"install \"{package.PackageName}\" -Source \"https://api.nuget.org/v3/index.json\" -PreRelease -ExcludeVersion -OutputDirectory \"{packagePath.FullPath}\"{(!string.IsNullOrWhiteSpace(package.Version) ? $" -Version \"{package.Version}\"" : string.Empty)}";
            var fallbackarguments = $"install \"{package.PackageName}\" -Source \"https://api.nuget.org/v3/index.json\" -Source \"https://www.myget.org/F/xunit/api/v3/index.json\" -Source \"https://dotnet.myget.org/F/dotnet-core/api/v3/index.json\" -Source \"https://dotnet.myget.org/F/cli-deps/api/v3/index.json\" -PreRelease -ExcludeVersion -OutputDirectory \"{packagePath.FullPath}\"{(!string.IsNullOrWhiteSpace(package.Version) ? $" -Version \"{package.Version}\"" : string.Empty)}";

            ExecuteNuget(nugetToolPath, arguments, fallbackarguments, 3);

            // Return the installation directory.
            return packagePath.Combine(package.PackageName);
        }