当前位置: 首页>>代码示例>>C#>>正文


C# NuGet.ZipPackage类代码示例

本文整理汇总了C#中NuGet.ZipPackage的典型用法代码示例。如果您正苦于以下问题:C# ZipPackage类的具体用法?C# ZipPackage怎么用?C# ZipPackage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ZipPackage类属于NuGet命名空间,在下文中一共展示了ZipPackage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EigenUpdateWithoutUpdateURL

        public void EigenUpdateWithoutUpdateURL()
        {
            string dir;
            string outDir;

            using (Utility.WithTempDirectory(out outDir))
            using (IntegrationTestHelper.WithFakeInstallDirectory(out dir)) {
                var di = new DirectoryInfo(dir);
                var progress = new Subject<int>();

                var bundledRelease = ReleaseEntry.GenerateFromFile(di.GetFiles("*.nupkg").First().FullName);
                var fixture = new InstallManager(bundledRelease, outDir);
                var pkg = new ZipPackage(Path.Combine(dir, "SampleUpdatingApp.1.1.0.0.nupkg"));

                var progressValues = new List<int>();
                progress.Subscribe(progressValues.Add);

                fixture.ExecuteInstall(dir, pkg, progress).Wait();

                var filesToLookFor = new[] {
                    "SampleUpdatingApp\\app-1.1.0.0\\SampleUpdatingApp.exe",
                    "SampleUpdatingApp\\packages\\RELEASES",
                    "SampleUpdatingApp\\packages\\SampleUpdatingApp.1.1.0.0.nupkg",
                };

                filesToLookFor.ForEach(f => Assert.True(File.Exists(Path.Combine(outDir, f)), "Could not find file: " + f));

                // Progress should be monotonically increasing
                progressValues.Count.ShouldBeGreaterThan(2);
                progressValues.Zip(progressValues.Skip(1), (prev, cur) => cur - prev).All(x => x > 0).ShouldBeTrue();
            }
        }
开发者ID:rzhw,项目名称:Squirrel.Windows,代码行数:32,代码来源:InstallManagerTests.cs

示例2: ReleasePackageIntegrationTest

        public void ReleasePackageIntegrationTest()
        {
            var inputPackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.1.0-pre.nupkg");
            var outputPackage = Path.GetTempFileName() + ".nupkg";
            var sourceDir = IntegrationTestHelper.GetPath("fixtures", "packages");

            var fixture = new ReleasePackage(inputPackage);
            (new DirectoryInfo(sourceDir)).Exists.ShouldBeTrue();

            try {
                fixture.CreateReleasePackage(outputPackage, sourceDir);

                this.Log().Info("Resulting package is at {0}", outputPackage);
                var pkg = new ZipPackage(outputPackage);

                int refs = pkg.FrameworkAssemblies.Count();
                this.Log().Info("Found {0} refs", refs);
                refs.ShouldEqual(0);

                this.Log().Info("Files in release package:");

                List<IPackageFile> files = pkg.GetFiles().ToList();
                files.ForEach(x => this.Log().Info(x.Path));

                List<string> nonDesktopPaths = new[] {"sl", "winrt", "netcore", "win8", "windows8", "MonoAndroid", "MonoTouch", "MonoMac", "wp", }
                    .Select(x => @"lib\" + x)
                    .ToList();

                files.Any(x => nonDesktopPaths.Any(y => x.Path.ToLowerInvariant().Contains(y.ToLowerInvariant()))).ShouldBeFalse();
                files.Any(x => x.Path.ToLowerInvariant().EndsWith(@".xml")).ShouldBeFalse();
            } finally {
                File.Delete(outputPackage);
            }
        }
开发者ID:RxSmart,项目名称:Squirrel.Windows,代码行数:34,代码来源:ReleasePackageTests.cs

示例3: ApplyDeltaPackageSmokeTest

        public void ApplyDeltaPackageSmokeTest()
        {
            var basePackage = new ReleasePackage(IntegrationTestHelper.GetPath("fixtures", "Shimmer.Core.1.0.0.0-full.nupkg"));
            var deltaPackage = new ReleasePackage(IntegrationTestHelper.GetPath("fixtures", "Shimmer.Core.1.1.0.0-delta.nupkg"));
            var expectedPackageFile = IntegrationTestHelper.GetPath("fixtures", "Shimmer.Core.1.1.0.0-full.nupkg");
            var outFile = Path.GetTempFileName() + ".nupkg";

            try {
                basePackage.ApplyDeltaPackage(deltaPackage, outFile);
                var result = new ZipPackage(outFile);
                var expected = new ZipPackage(expectedPackageFile);

                result.Id.ShouldEqual(expected.Id);
                result.Version.ShouldEqual(expected.Version);

                this.Log().Info("Expected file list:");
                expected.GetFiles().Select(x => x.Path).OrderBy(x => x).ForEach(x => this.Log().Info(x));

                this.Log().Info("Actual file list:");
                result.GetFiles().Select(x => x.Path).OrderBy(x => x).ForEach(x => this.Log().Info(x));

                Enumerable.Zip(
                    expected.GetFiles().Select(x => x.Path).OrderBy(x => x),
                    result.GetFiles().Select(x => x.Path).OrderBy(x => x),
                    (e, a) => e == a
                ).All(x => x).ShouldBeTrue();
            } finally {
                if (File.Exists(outFile)) {
                    File.Delete(outFile);
                }
            }
        }
开发者ID:edvillan15,项目名称:Shimmer,代码行数:32,代码来源:ReleasePackageTests.cs

示例4: Main

        static void Main(string[] args)
        {
            Console.WriteLine("Create NuGet Package via Code");
            ManifestMetadata metadata = new ManifestMetadata()
            {
                Authors = "Authors Name",
                Version = "1.0.0.0",
                Id = "NuGetId",
                Description = "NuGet Package Description goes here!",
            };

            PackageBuilder builder = new PackageBuilder();


            var path = AppDomain.CurrentDomain.BaseDirectory + "..\\..\\DemoContent\\";

            builder.PopulateFiles(path, new[] { new ManifestFile { Source = "**", Target = "content" } });
            builder.Populate(metadata);

            using (FileStream stream = File.Open("test.nupkg", FileMode.OpenOrCreate))
            {
                builder.Save(stream);
            }

            Console.WriteLine("... and extract NuGet Package via Code");

            NuGet.ZipPackage package = new ZipPackage("test.nupkg");
            var content = package.GetContentFiles();

            Console.WriteLine("Package Id: " + package.Id);
            Console.WriteLine("Content-Files-Count: " + content.Count());

            Console.ReadLine();
        }
开发者ID:ledgarl,项目名称:Samples,代码行数:34,代码来源:Program.cs

示例5: NuspecMissingRequiredFieldsThrowsExceptions

        public void NuspecMissingRequiredFieldsThrowsExceptions()
        {
            var path = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Core.1.1.0.0.nupkg");
            var zp = new ZipPackage(path);

            //Use reflection to grab an instance of the private method
            var checkIfNuspecHasRequiredFields = typeof(ParseCommands).GetMethod("checkIfNuspecHasRequiredFields",
                BindingFlags.Static | BindingFlags.NonPublic);

            zp.Id = "";
            //Blank id exception
            Assert.Throws<TargetInvocationException>(() => checkIfNuspecHasRequiredFields.Invoke(null, new object[] { zp, "Path" }));

            zp.Id = "K";
            //zp.Version = "";
            //TODO: Test a blank version somehow
            
            //zp.Version = "1.0";
            zp.Authors = new string[0];
            //Blank authors exception
            Assert.Throws<TargetInvocationException>(() => checkIfNuspecHasRequiredFields.Invoke(null, new object[] { zp, "Path" }));

            zp.Authors = new[] { "AuthorName" };
            zp.Description = "";
            
            //Blank description exception
            Assert.Throws<TargetInvocationException>(() => checkIfNuspecHasRequiredFields.Invoke(null, new object[] { zp, "Path" }));
        }
开发者ID:rzhw,项目名称:Squirrel.Windows,代码行数:28,代码来源:ParseCommandsTests.cs

示例6: DetectFrameworkVersion

        public void DetectFrameworkVersion(string packageName, FrameworkVersion expected)
        {
            var path = IntegrationTestHelper.GetPath("fixtures", packageName);

            var zip = new ZipPackage(path);

            Assert.Equal(expected, zip.DetectFrameworkVersion());
        }
开发者ID:ralberts,项目名称:Shimmer,代码行数:8,代码来源:PackageExtensionsTests.cs

示例7: IsNuGetPublished

        public static bool IsNuGetPublished (this ICakeContext context, FilePath file, string nugetSource = DefaultNuGetSource)
        {
            var f = file.MakeAbsolute (context.Environment).FullPath;

            var pkg = new ZipPackage (f);

            return IsNuGetPublished (context, pkg.Id, pkg.Version, nugetSource);
        }
开发者ID:Redth,项目名称:Cake.ExtendedNuGet,代码行数:8,代码来源:Aliases.cs

示例8: GetNuGetPackageVersion

        public static SemanticVersion GetNuGetPackageVersion (this ICakeContext context, FilePath file)
        {
            var f = file.MakeAbsolute (context.Environment).FullPath;

            var p = new ZipPackage (f);

            return p.Version;
        }
开发者ID:Redth,项目名称:Cake.ExtendedNuGet,代码行数:8,代码来源:Aliases.cs

示例9: GetNuGetPackageId

        public static string GetNuGetPackageId (this ICakeContext context, FilePath file)
        {
            var f = file.MakeAbsolute (context.Environment).FullPath;

            var p = new ZipPackage (f);

            return p.Id;
        }
开发者ID:Redth,项目名称:Cake.ExtendedNuGet,代码行数:8,代码来源:Aliases.cs

示例10: Push

        public void Push(string url, string key, Stream stream)
        {
            var package = new ZipPackage(stream);
            stream = package.GetStream();

            var server = new PackageServer(url, "SymbolSource");
            server.PushPackage(key, package, stream.Length, 5000, false);
        }
开发者ID:n3rd,项目名称:SymbolSource.Community,代码行数:8,代码来源:TestHelper.cs

示例11: PublishPackage

        public void PublishPackage(string file, string apiKey)
        {
            var packageServer = new PackageServer(Feed.NuGetV2.Url, "ripple");
            var package = new ZipPackage(file);

            RippleLog.Info("Publishing " + file);
            packageServer.PushPackage(apiKey, package.GetStream, (int)60.Minutes().TotalMilliseconds);
        }
开发者ID:bobpace,项目名称:ripple,代码行数:8,代码来源:IPublishingService.cs

示例12: TryBuild

        public bool TryBuild(byte[] bytes, out Package package)
        {
            package = null;
            try
            {
                using (var stream = new MemoryStream(bytes))
                {
                    var zipPackage = new ZipPackage(stream);
                    if (zipPackage.Id.IsTooLargeString() || zipPackage.Version.ToString().IsTooLargeString())
                    {
                        return false;
                    }

                    var now = dateTimeService.UtcNow;
                    package = new Package
                    {
                        Id = zipPackage.Id,
                        Version = zipPackage.Version.ToString(),
                        DisplayTitle = zipPackage.Title.ToStringSafe(),
                        IsAbsoluteLatestVersion = zipPackage.IsAbsoluteLatestVersion,
                        IsLatestVersion = zipPackage.IsLatestVersion,
                        IsPrerelease = zipPackage.IsPrerelease(),
                        PackageHash = cryptoService.Hash(bytes),
                        PackageHashAlgorithm = cryptoService.HashAlgorithmId,
                        PackageSize = bytes.LongLength,
                        Created = now,
                        LastUpdated = now,
                        Published = now,
                        Owners = zipPackage.Owners.Flatten().ToStringSafe(),
                        Authors = zipPackage.Authors.Flatten().ToStringSafe(),
                        Listed = true,
                        RequireLicenseAcceptance = zipPackage.RequireLicenseAcceptance,
                        Language = zipPackage.Language.ToStringSafe(),
                        DevelopmentDependency = zipPackage.DevelopmentDependency,
                        Title = zipPackage.Title.ToStringSafe(),
                        Tags = zipPackage.Tags.ToStringSafe(),
                        Copyright = zipPackage.Copyright.ToStringSafe(),
                        Dependencies = "".ToStringSafe(),
                        IconUrl = zipPackage.IconUrl.ToStringSafe(),
                        LicenseUrl = zipPackage.LicenseUrl.ToStringSafe(),
                        ProjectUrl = zipPackage.ProjectUrl.ToStringSafe(),
                        Description = zipPackage.Description.ToStringSafe(),
                        ReleaseNotes = zipPackage.ReleaseNotes.ToStringSafe(),
                        Summary = zipPackage.Summary.ToStringSafe(),
                        DownloadCount = 0,
                        Score = 0f,
                        VersionDownloadCount = 0,
                        BlobId = guidGenerator.NewGuid()
                    };
                    return true;
                }
            }
            catch (Exception)
            {
                return false;
            }
        }
开发者ID:Pliner,项目名称:TinyFeed,代码行数:57,代码来源:PackageBuilder.cs

示例13: LoadAsync

        public async Task<Package> LoadAsync(string id, string version) {
            var logger = _loggerFactory.CreateLogger<NuGetPackageLoader>();

            var sourceProvider = new PackageSourceProvider(
                NullSettings.Instance,
                new[] {
                    new PackageSource(NuGetConstants.DefaultFeedUrl),
                    new PackageSource("https://www.myget.org/F/aspnetvnext/api/v2"),
                });

            var feeds = sourceProvider
                .LoadPackageSources()
                .Select(source =>
                    PackageSourceUtils.CreatePackageFeed(
                        source,
                        noCache: false,
                        ignoreFailedSources: false,
                        reports: logger.CreateReports()))
                .Where(f => f != null);

            logger.LogInformation($"Looking up {id} v{version} from nuget");

            var packages = (await Task.WhenAll(feeds.Select(feed => feed.FindPackagesByIdAsync(id))))
                .SelectMany(_ => _)
                .OrderByDescending(p => p.Version);

            var package = version == null
                ? packages.FirstOrDefault()
                : packages.FirstOrDefault(p => p.Version == new SemanticVersion(version));

            if (package == null) {
                logger.LogError($"Unable to locate {id} v{version}");
                return null;
            }

            logger.LogInformation($"Found version {package.Version} of {package.Id}");

            var pkgStreams = await Task.WhenAll(feeds.Select(feed => {
                try {
                    return feed.OpenNupkgStreamAsync(package);
                } catch {
                    return null;
                }
            }));
            var pkgStream = pkgStreams.FirstOrDefault(s => s != null);
            var zipPackage = new ZipPackage(pkgStream);

            if (zipPackage == null) {
                logger.LogError($"Unable to open package stream for {id} v{version}");
                return null;
            }

            return zipPackage.ToPackage(packages.Select(p => p.Version.ToString()).ToList(), logger);
        }
开发者ID:Nemo157,项目名称:DocNuget,代码行数:54,代码来源:NuGetPackageLoader.cs

示例14: AddFolder

        public void AddFolder(string folderPath)
        {
            log.Debug("Using package versions from folder: " + folderPath);
            foreach (var file in Directory.GetFiles(folderPath, "*.nupkg", SearchOption.AllDirectories))
            {
                log.Debug("Package file: " + file);
                var package = new ZipPackage(file);

                Add(package.Id, package.Version.ToString());
            }
        }
开发者ID:rodrickyu,项目名称:Octopus-Tools,代码行数:11,代码来源:PackageVersionResolver.cs

示例15: ExecuteCommand

        public override void ExecuteCommand()
        {
            Log.Info("Getting all package metadata...");
            var packages = GetAllPackages();
            Log.Info("Getting packages which have target framework data...");
            var alreadyPopulatedPackageKeys = GetAlreadyPopulatedPackageKeys();
            Log.Info("Calculating minimal difference set...");
            var packageKeysToPopulate = packages.Keys.Except(alreadyPopulatedPackageKeys).ToList();

            var totalCount = packageKeysToPopulate.Count;
            var processedCount = 0;
            Log.Info(
                "Populating frameworks for {0} packages on '{1}',",
                totalCount,
                ConnectionString);

            Parallel.ForEach(packageKeysToPopulate, new ParallelOptions { MaxDegreeOfParallelism = 10 }, packageIdToPopulate =>
            {
                var package = packages[packageIdToPopulate];

                try
                {
                    var downloadPath = DownloadPackage(package);
                    var nugetPackage = new ZipPackage(downloadPath);

                    var supportedFrameworks = GetSupportedFrameworks(nugetPackage);
                    if (!WhatIf)
                    {
                        PopulateFrameworks(package, supportedFrameworks);
                    }

                    File.Delete(downloadPath);

                    Interlocked.Increment(ref processedCount);
                    Log.Info(
                        "Populated frameworks for package '{0}.{1}' ({2} of {3}).",
                        package.Id,
                        package.Version,
                        processedCount,
                        totalCount);
                }
                catch (Exception ex)
                {
                    Interlocked.Increment(ref processedCount);
                    Log.Error(
                        "Error populating frameworks for package '{0}.{1}' ({2} of {3}): {4}.",
                        package.Id,
                        package.Version,
                        processedCount,
                        totalCount,
                        ex.Message);
                }
            });
        }
开发者ID:bhuvak,项目名称:NuGetOperations,代码行数:54,代码来源:PopulatePackageFrameworksTask.cs


注:本文中的NuGet.ZipPackage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。