예제 #1
0
        public static async Task <IEnumerable <string> > CopySatelliteFilesAsync(PackageIdentity packageIdentity, PackagePathResolver packagePathResolver,
                                                                                 PackageSaveModes packageSaveMode, CancellationToken token)
        {
            IEnumerable <string> satelliteFilesCopied = Enumerable.Empty <string>();

            if (packageIdentity == null)
            {
                throw new ArgumentNullException("packageIdentity");
            }

            if (packagePathResolver == null)
            {
                throw new ArgumentNullException("packagePathResolver");
            }

            string nupkgFilePath = packagePathResolver.GetInstalledPackageFilePath(packageIdentity);

            if (File.Exists(nupkgFilePath))
            {
                using (var packageStream = File.OpenRead(nupkgFilePath))
                {
                    string language;
                    string runtimePackageDirectory;
                    IEnumerable <ZipArchiveEntry> satelliteFiles;
                    if (PackageHelper.GetSatelliteFiles(packageStream, packageIdentity, packagePathResolver, out language, out runtimePackageDirectory, out satelliteFiles))
                    {
                        // Now, add all the satellite files collected from the package to the runtime package folder(s)
                        satelliteFilesCopied = await PackageHelper.CreatePackageFiles(satelliteFiles, runtimePackageDirectory, packageSaveMode, token);
                    }
                }
            }

            return(satelliteFilesCopied);
        }
예제 #2
0
        private static IEnumerable <string> CopySatelliteFiles(
            PackageReaderBase packageReader,
            PackagePathResolver packagePathResolver,
            PackageSaveMode packageSaveMode,
            PackageExtractionContext packageExtractionContext,
            CancellationToken token)
        {
            if (packageReader == null)
            {
                throw new ArgumentNullException(nameof(packageReader));
            }

            if (packagePathResolver == null)
            {
                throw new ArgumentNullException(nameof(packagePathResolver));
            }

            if (packageExtractionContext == null)
            {
                throw new ArgumentNullException(nameof(packageExtractionContext));
            }

            var satelliteFilesCopied = Enumerable.Empty <string>();

            string runtimePackageDirectory;
            var    satelliteFiles = PackageHelper
                                    .GetSatelliteFiles(packageReader, packagePathResolver, out runtimePackageDirectory)
                                    .Where(file => PackageHelper.IsPackageFile(file, packageSaveMode))
                                    .ToList();

            if (satelliteFiles.Count > 0)
            {
                var packageFileExtractor = new PackageFileExtractor(satelliteFiles, packageExtractionContext.XmlDocFileSaveMode);

                // Now, add all the satellite files collected from the package to the runtime package folder(s)
                satelliteFilesCopied = packageReader.CopyFiles(
                    runtimePackageDirectory,
                    satelliteFiles,
                    packageFileExtractor.ExtractPackageFile,
                    packageExtractionContext.Logger,
                    token);
            }

            return(satelliteFilesCopied);
        }
예제 #3
0
        public static async Task <Tuple <string, IEnumerable <ZipFilePair> > > GetInstalledSatelliteFiles(Stream packageStream,
                                                                                                          PackageIdentity packageIdentity,
                                                                                                          PackagePathResolver packagePathResolver,
                                                                                                          PackageSaveModes packageSaveMode,
                                                                                                          CancellationToken token)
        {
            List <ZipFilePair>            installedSatelliteFiles = new List <ZipFilePair>();
            string                        language;
            string                        runtimePackageDirectory;
            IEnumerable <ZipArchiveEntry> satelliteFileEntries;

            if (PackageHelper.GetSatelliteFiles(packageStream, packageIdentity, packagePathResolver, out language, out runtimePackageDirectory, out satelliteFileEntries))
            {
                var satelliteFiles = await GetPackageFiles(satelliteFileEntries, runtimePackageDirectory, packageSaveMode, token);

                installedSatelliteFiles.AddRange(GetInstalledPackageFiles(satelliteFiles));
            }

            return(new Tuple <string, IEnumerable <ZipFilePair> >(runtimePackageDirectory, installedSatelliteFiles));
        }