Exemplo n.º 1
0
        public async Task <IEnumerable <string> > ExtractPackageAsync(string packagePath, DirectoryPath targetFolder)
        {
            await using FileStream packageStream = File.OpenRead(packagePath);
            PackageFolderReader      packageReader            = new PackageFolderReader(targetFolder.Value);
            PackageExtractionContext packageExtractionContext = new PackageExtractionContext(
                PackageSaveMode.Defaultv3,
                XmlDocFileSaveMode.None,
                null,
                _logger);
            NuGetPackagePathResolver packagePathResolver = new NuGetPackagePathResolver(targetFolder.Value);
            CancellationToken        cancellationToken   = CancellationToken.None;

            var allFilesInPackage = await PackageExtractor.ExtractPackageAsync(
                targetFolder.Value,
                packageStream,
                packagePathResolver,
                packageExtractionContext,
                cancellationToken);

            if (!OperatingSystem.IsWindows())
            {
                foreach (FilePath filePath in FindAllFilesNeedExecutablePermission(allFilesInPackage, targetFolder.Value))
                {
                    _filePermissionSetter.Set755Permission(filePath.Value);
                }
            }

            return(allFilesInPackage);
        }
Exemplo n.º 2
0
        public async Task <IEnumerable <string> > ExtractPackageAsync(string packagePath, DirectoryPath targetFolder)
        {
            await using FileStream packageStream = File.OpenRead(packagePath);
            PackageFolderReader      packageReader            = new PackageFolderReader(targetFolder.Value);
            PackageExtractionContext packageExtractionContext = new PackageExtractionContext(
                PackageSaveMode.Defaultv3,
                XmlDocFileSaveMode.None,
                null,
                _verboseLogger);
            NuGetPackagePathResolver packagePathResolver = new NuGetPackagePathResolver(targetFolder.Value);
            CancellationToken        cancellationToken   = CancellationToken.None;

            var allFilesInPackage = await PackageExtractor.ExtractPackageAsync(
                targetFolder.Value,
                packageStream,
                packagePathResolver,
                packageExtractionContext,
                cancellationToken);

            if (!OperatingSystem.IsWindows())
            {
                string workloadUnixFilePermissions = allFilesInPackage.SingleOrDefault(p =>
                                                                                       Path.GetRelativePath(targetFolder.Value, p).Equals("data/UnixFilePermissions.xml",
                                                                                                                                          StringComparison.OrdinalIgnoreCase));

                if (workloadUnixFilePermissions != default)
                {
                    var permissionList = WorkloadUnixFilePermissions.FileList.Deserialize(workloadUnixFilePermissions);
                    foreach (var fileAndPermission in permissionList.File)
                    {
                        _filePermissionSetter
                        .SetPermission(
                            Path.Combine(targetFolder.Value, fileAndPermission.Path),
                            fileAndPermission.Permission);
                    }
                }
                else
                {
                    // https://github.com/dotnet/sdk/issues/18239
                    foreach (FilePath filePath in FindAllFilesNeedExecutablePermission(allFilesInPackage,
                                                                                       targetFolder.Value))
                    {
                        _filePermissionSetter.SetPermission(filePath.Value, "755");
                    }
                }
            }

            return(allFilesInPackage);
        }
Exemplo n.º 3
0
        public async Task <IEnumerable <string> > ExtractPackageAsync(string packagePath, string targetFolder)
        {
            await using FileStream packageStream = File.OpenRead(packagePath);
            PackageFolderReader      packageReader            = new PackageFolderReader(targetFolder);
            PackageExtractionContext packageExtractionContext = new PackageExtractionContext(
                PackageSaveMode.Defaultv3,
                XmlDocFileSaveMode.None,
                null,
                _logger);
            NuGetPackagePathResolver packagePathResolver = new NuGetPackagePathResolver(targetFolder);
            CancellationToken        cancellationToken   = CancellationToken.None;

            return(await PackageExtractor.ExtractPackageAsync(
                       targetFolder,
                       packageStream,
                       packagePathResolver,
                       packageExtractionContext,
                       cancellationToken));
        }
Exemplo n.º 4
0
        public async Task <IEnumerable <string> > ExtractPackageAsync(string packagePath, string targetFolder)
        {
            using var packageStream = File.OpenRead(packagePath);
            var packageReader            = new PackageFolderReader(targetFolder);
            var packageExtractionContext = new PackageExtractionContext(
                PackageSaveMode.Defaultv3,
                XmlDocFileSaveMode.None,
                clientPolicyContext: null,
                logger: _logger);
            var packagePathResolver = new NuGetPackagePathResolver(targetFolder);
            var cancellationToken   = CancellationToken.None;

            return(await PackageExtractor.ExtractPackageAsync(
                       source : targetFolder,
                       packageStream : packageStream,
                       packagePathResolver : packagePathResolver,
                       packageExtractionContext : packageExtractionContext,
                       token : cancellationToken));
        }