コード例 #1
0
        public async Task Test_ExtractionIgnoresNupkgFile()
        {
            // Arrange
            var packageIdentity = new PackageIdentity("packageA", new NuGetVersion("2.0.3"));

            using (var packagesDirectory = TestDirectory.Create())
            {
                var pathResolver    = new VersionFolderPathResolver(packagesDirectory);
                var packageFileInfo = await TestPackagesCore.GetPackageWithNupkgAtRoot(
                    packagesDirectory,
                    packageIdentity.Id,
                    packageIdentity.Version.ToNormalizedString());

                var packageExtractionContext = new PackageExtractionContext(
                    packageSaveMode: PackageSaveMode.Defaultv3,
                    xmlDocFileSaveMode: XmlDocFileSaveMode.None,
                    logger: NullLogger.Instance,
                    signedPackageVerifier: null,
                    signedPackageVerifierSettings: null);

                var versionFolderPathResolver = new VersionFolderPathResolver(packagesDirectory);

                // Act
                using (var packageDownloader = new LocalPackageArchiveDownloader(
                           null,
                           packageFileInfo.FullName,
                           packageIdentity,
                           NullLogger.Instance))
                {
                    await PackageExtractor.InstallFromSourceAsync(
                        packageIdentity,
                        packageDownloader,
                        versionFolderPathResolver,
                        packageExtractionContext,
                        CancellationToken.None);
                }

                // Assert
                var packageVersionDirectory = pathResolver.GetInstallPath(packageIdentity.Id, packageIdentity.Version);

                AssertDirectoryExists(packageVersionDirectory);
                AssertFileExists(packageVersionDirectory, pathResolver.GetPackageFilePath(packageIdentity.Id, packageIdentity.Version));
                AssertFileExists(packageVersionDirectory, pathResolver.GetManifestFileName(packageIdentity.Id, packageIdentity.Version));
                AssertFileExists(packageVersionDirectory, "lib", "net45", "A.dll");

                var nupkgPath     = pathResolver.GetPackageFilePath(packageIdentity.Id, packageIdentity.Version);
                var nupkgFileInfo = new FileInfo(nupkgPath);
                Assert.True(File.Exists(nupkgFileInfo.FullName));
                Assert.NotEqual(0, nupkgFileInfo.Length);

                var bnupkgPath     = Path.Combine(packageVersionDirectory, "lib", "net45", "B.nupkg");
                var bnupkgFileInfo = new FileInfo(bnupkgPath);
                Assert.True(File.Exists(bnupkgFileInfo.FullName));
                Assert.Equal(0, bnupkgFileInfo.Length);
            }
        }