GetFiles() public method

public GetFiles ( ) : IEnumerable
return IEnumerable
        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);
                }
            }
        }
Beispiel #2
0
        public void CreateDeltaPackageIntegrationTest()
        {
            var basePackage = IntegrationTestHelper.GetPath("fixtures", "NSync.Core.1.0.0.0.nupkg");
            var newPackage = IntegrationTestHelper.GetPath("fixtures", "NSync.Core.1.1.0.0.nupkg");

            var sourceDir = IntegrationTestHelper.GetPath("..", "packages");
            (new DirectoryInfo(sourceDir)).Exists.ShouldBeTrue();

            var baseFixture = new ReleasePackage(basePackage);
            var fixture = new ReleasePackage(newPackage);

            var tempFiles = Enumerable.Range(0, 3)
                .Select(_ => Path.GetTempPath() + Guid.NewGuid().ToString() + ".nupkg")
                .ToArray();

            try {
                baseFixture.CreateReleasePackage(tempFiles[0], sourceDir);
                fixture.CreateReleasePackage(tempFiles[1], sourceDir);

                (new FileInfo(baseFixture.ReleasePackageFile)).Exists.ShouldBeTrue();
                (new FileInfo(fixture.ReleasePackageFile)).Exists.ShouldBeTrue();

                fixture.CreateDeltaPackage(baseFixture, tempFiles[2]);

                var fullPkg = new ZipPackage(tempFiles[1]);
                var deltaPkg = new ZipPackage(tempFiles[2]);

                fullPkg.Id.ShouldEqual(deltaPkg.Id);
                fullPkg.Version.CompareTo(deltaPkg.Version).ShouldEqual(0);

                // v1.1 adds a dependency on DotNetZip
                deltaPkg.GetFiles()
                    .Any(x => x.Path.ToLowerInvariant().Contains("ionic.zip"))
                    .ShouldBeTrue();

                // All the other files should be diffs
                deltaPkg.GetFiles()
                    .Where(x => !x.Path.ToLowerInvariant().Contains("ionic.zip"))
                    .All(x => x.Path.ToLowerInvariant().EndsWith("diff"))
                    .ShouldBeTrue();

                // Delta packages should be smaller than the original!
                var fileInfos = tempFiles.Select(x => new FileInfo(x)).ToArray();
                this.Log().Info("Base Size: {0}, Current Size: {1}, Delta Size: {2}",
                    fileInfos[0].Length, fileInfos[1].Length, fileInfos[2].Length);

                (fileInfos[2].Length - fileInfos[1].Length).ShouldBeLessThan(0);

            } finally {
                tempFiles.ForEach(File.Delete);
            }
        }
        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);
            }
        }
        public void Build_And_Packaged_XCopy_Has_Correct_Metadata()
        {
            System.Environment.CurrentDirectory = "samples".MapVcsRoot();

            MsBuild("PowerDeploy.Sample.XCopy\\PowerDeploy.Sample.XCopy.csproj /t:clean,build /p:RunOctoPack=true /p:OctoPackPackageVersion=1.3.3.7 /p:Configuration=Release /v:m");

            Assert.IsTrue(File.Exists(@"PowerDeploy.Sample.XCopy\obj\octopacked\PowerDeploy.Sample.XCopy.1.3.3.7.nupkg"));

            var nupkg = new ZipPackage(@"PowerDeploy.Sample.XCopy\obj\octopacked\PowerDeploy.Sample.XCopy.1.3.3.7.nupkg");

            Assert.AreEqual("1.3.3.7", nupkg.Version.ToString());
            Assert.AreEqual("PowerDeploy.Sample.XCopy", nupkg.Id);
            Assert.IsTrue(nupkg.GetFiles().Any(f => f.Path.Contains("powerdeploy.template.xml")));
        }
        public void CanResolveMultipleLevelsOfDependencies()
        {
            var inputPackage = IntegrationTestHelper.GetPath("fixtures", "SampleUpdatingApp.1.0.0.0.nupkg");
            var outputPackage = Path.GetTempFileName() + ".nupkg";
            var sourceDir = IntegrationTestHelper.GetPath("..", "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:");
                pkg.GetFiles().ForEach(x => this.Log().Info(x.Path));

                var filesToLookFor = new[] {
                    "System.Reactive.Core.dll",
                    "ReactiveUI.dll",
                    "MarkdownSharp.dll",
                    "SampleUpdatingApp.exe",
                };

                filesToLookFor.ForEach(name => {
                    this.Log().Info("Looking for {0}", name);
                    pkg.GetFiles().Any(y => y.Path.ToLowerInvariant().Contains(name.ToLowerInvariant())).ShouldBeTrue();
                });
            } finally {
                File.Delete(outputPackage);
            }
        }
Beispiel #6
0
        public void CreatePackage(HttpContextBase context)
        {
            var request = context.Request;
            var stream = request.Files.Count > 0 ? request.Files[0].InputStream : request.InputStream;
            var package = new ZipPackage(stream);

            var symbolFiles = package.GetFiles("lib").Where(f => Path.GetExtension(f.Path) == ".pdb").ToList();

            foreach (var symbolFile in symbolFiles)
                ProcessSymbolFile(symbolFile, package);

            stream.Position = 0;

            if (IsSymbolPackage(package, symbolFiles))
                symbolPackageService.CreatePackage(context);
            else
                packageService.CreatePackage(context);
        }
Beispiel #7
0
        public void GetSource(RequestContext context)
        {
            var packageId = context.RouteData.Values["id"].ToString();
            var version = context.RouteData.Values["version"].ToString();
            var path = Path.Combine("src", context.RouteData.Values["path"].ToString().Replace('/', '\\'));

            var package = new ZipPackage(symbolPackagePathResolver.GetSymbolPackagePath(packageId, version));

            string directory = Path.GetDirectoryName(path);
            var file = package.GetFiles(directory).FirstOrDefault(f => string.Equals(f.Path, path, StringComparison.InvariantCultureIgnoreCase));
            var response = context.HttpContext.Response;
            if (file == null)
            {
                response.StatusCode = 404;
                return;
            }
            response.ContentType = "binary/octet-stream";
            file.GetStream().CopyTo(response.OutputStream);
        }
        public void Configure_XCopy_Sample_Project_With_Mocked_Environment()
        {
            System.Environment.CurrentDirectory = "samples".MapVcsRoot();

            MsBuild("PowerDeploy.Sample.XCopy\\PowerDeploy.Sample.XCopy.csproj /t:clean,build /p:RunOctoPack=true /p:OctoPackPackageVersion=1.3.3.7 /p:Configuration=Release /v:m");

            var environmentMock = new Mock<IEnvironmentProvider>();
            environmentMock.Setup(prov => prov.GetEnvironment(It.IsAny<string>())).Returns(GetUnitEnvironment);

            var outputPath = FileSystem.CreateTempWorkingDir();

            var target = new PackageManager(environmentMock.Object);
            target.ConfigurePackageByEnvironment(@"PowerDeploy.Sample.XCopy\obj\octopacked\PowerDeploy.Sample.XCopy.1.3.3.7.nupkg", "Unit", outputPath);

            // check if all template files are parsed
            var nupkg = new ZipPackage(Path.Combine(outputPath, "PowerDeploy.Sample.XCopy_v1.3.3.7_UNIT.nupkg"));
            Assert.IsFalse(nupkg.GetFiles().Any(f => f.Path.Contains(".template.")));

            AssertPackage(Path.Combine(outputPath, "PowerDeploy.Sample.XCopy_v1.3.3.7_UNIT.nupkg"),
                pkg => pkg.AssertFileContent(new Dictionary<string, string>()
                {
                    {
                        "powerdeploy.xml",
                        @"<?xml version=""1.0"" encoding=""utf-8"" ?>
                          <package type=""xcopy"" environment=""UNIT"">
                              <destination>c:\temp</destination>
                          </package>".ToXmlOneLine()
                    },
                    {
                        "App.config",
                        @"<?xml version=""1.0"" encoding=""utf-8"" ?>
                          <configuration>
                            <appSettings>
                              <add key=""variable1"" value=""Val1"" />
                              <add key=""variable2"" value=""Val2"" />
                              <add key=""default.variable"" value=""defaultvalue"" />
                              <add key=""env"" value=""UNIT"" />
                            </appSettings>
                          </configuration>".ToXmlOneLine()
                    }
                }));
        }
        public void CreateDeltaPackageIntegrationTest()
        {
            var basePackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.1.0-pre.nupkg");
            var newPackage = IntegrationTestHelper.GetPath("fixtures", "Squirrel.Tests.0.2.0-pre.nupkg");

            var sourceDir = IntegrationTestHelper.GetPath("fixtures", "packages");
            (new DirectoryInfo(sourceDir)).Exists.ShouldBeTrue();

            var baseFixture = new ReleasePackage(basePackage);
            var fixture = new ReleasePackage(newPackage);

            var tempFiles = Enumerable.Range(0, 3)
                .Select(_ => Path.GetTempPath() + Guid.NewGuid().ToString() + ".nupkg")
                .ToArray();

            try {
                baseFixture.CreateReleasePackage(tempFiles[0], sourceDir);
                fixture.CreateReleasePackage(tempFiles[1], sourceDir);

                (new FileInfo(baseFixture.ReleasePackageFile)).Exists.ShouldBeTrue();
                (new FileInfo(fixture.ReleasePackageFile)).Exists.ShouldBeTrue();

                var deltaBuilder = new DeltaPackageBuilder();
                deltaBuilder.CreateDeltaPackage(baseFixture, fixture, tempFiles[2]);

                var fullPkg = new ZipPackage(tempFiles[1]);
                var deltaPkg = new ZipPackage(tempFiles[2]);

                //
                // Package Checks
                //

                fullPkg.Id.ShouldEqual(deltaPkg.Id);
                fullPkg.Version.CompareTo(deltaPkg.Version).ShouldEqual(0);

                // Delta packages should be smaller than the original!
                var fileInfos = tempFiles.Select(x => new FileInfo(x)).ToArray();
                this.Log().Info("Base Size: {0}, Current Size: {1}, Delta Size: {2}",
                    fileInfos[0].Length, fileInfos[1].Length, fileInfos[2].Length);

                (fileInfos[2].Length - fileInfos[1].Length).ShouldBeLessThan(0);

                //
                // File Checks
                ///

                var deltaPkgFiles = deltaPkg.GetFiles().ToList();
                deltaPkgFiles.Count.ShouldBeGreaterThan(0);

                this.Log().Info("Files in delta package:");
                deltaPkgFiles.ForEach(x => this.Log().Info(x.Path));

                var newFilesAdded = new[] {
                    "Newtonsoft.Json.dll",
                    "Refit.dll",
                    "Refit-Portable.dll",
                    "Castle.Core.dll",
                }.Select(x => x.ToLowerInvariant());

                // vNext adds a dependency on Refit
                newFilesAdded
                    .All(x => deltaPkgFiles.Any(y => y.Path.ToLowerInvariant().Contains(x)))
                    .ShouldBeTrue();

                // All the other files should be diffs and shasums
                deltaPkgFiles
                    .Where(x => !newFilesAdded.Any(y => x.Path.ToLowerInvariant().Contains(y)))
                    .All(x => x.Path.ToLowerInvariant().EndsWith("diff") || x.Path.ToLowerInvariant().EndsWith("shasum"))
                    .ShouldBeTrue();

                // Every .diff file should have a shasum file
                deltaPkg.GetFiles().Any(x => x.Path.ToLowerInvariant().EndsWith(".diff")).ShouldBeTrue();
                deltaPkg.GetFiles()
                    .Where(x => x.Path.ToLowerInvariant().EndsWith(".diff"))
                    .ForEach(x => {
                        var lookingFor = x.Path.Replace(".diff", ".shasum");
                        this.Log().Info("Looking for corresponding shasum file: {0}", lookingFor);
                        deltaPkg.GetFiles().Any(y => y.Path == lookingFor).ShouldBeTrue();
                    });
            } finally {
                tempFiles.ForEach(File.Delete);
            }
        }
        public void ReleasePackageIntegrationTest()
        {
            var inputPackage = IntegrationTestHelper.GetPath("fixtures", "Shimmer.Core.1.0.0.0.nupkg");
            var outputPackage = Path.GetTempFileName() + ".nupkg";
            var sourceDir = IntegrationTestHelper.GetPath("..", "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.References.Count();
                this.Log().Info("Found {0} refs", refs);
                refs.ShouldEqual(0);

                this.Log().Info("Files in release package:");
                pkg.GetFiles().ForEach(x => this.Log().Info(x.Path));

                pkg.GetFiles().Any(x => x.Path.ToLowerInvariant().Contains(@"lib\sl")).ShouldBeFalse();
                pkg.GetFiles().Any(x => x.Path.ToLowerInvariant().Contains(@".xml")).ShouldBeFalse();
            } finally {
                File.Delete(outputPackage);
            }
        }
        public override void ExecuteCommand()
        {
            Log.Trace("Getting latest packages...");
            var packages = GetLatestStablePackages();
            Log.Trace("Getting previously curated packages...");
            var alreadyCuratedPackageIds = GetAlreadyCuratedPackageIds();
            Log.Trace("Calculating minimum difference set...");
            var packageIdsToCurate = packages.Keys.Except(alreadyCuratedPackageIds).ToList();

            var totalCount = packageIdsToCurate.Count;
            var processedCount = 0;
            Log.Trace(
                "Curating {0} packages for the WebMatrix curated on '{1}',",
                totalCount,
                ConnectionString);

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

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

                    var shouldBeIncluded = nugetPackage.Tags != null && nugetPackage.Tags.ToLowerInvariant().Contains("aspnetwebpages");

                    if (!shouldBeIncluded)
                    {
                        shouldBeIncluded = true;
                        foreach (var file in nugetPackage.GetFiles())
                        {
                            var fi = new FileInfo(file.Path);
                            if (fi.Extension == ".ps1" || fi.Extension == ".t4")
                            {
                                shouldBeIncluded = false;
                                break;
                            }
                        }
                    }

                    if (shouldBeIncluded)
                    {
                        AddPackageToCuratedFeed(package);
                    }

                    File.Delete(downloadPath);

                    Interlocked.Increment(ref processedCount);
                    Log.Info(
                        "{2} package '{0}.{1}' ({3} of {4}).",
                        package.Id,
                        package.Version,
                        shouldBeIncluded ? "Curated" : "Ignored",
                        processedCount,
                        totalCount);
                }
                catch(Exception ex)
                {
                    Interlocked.Increment(ref processedCount);
                    Log.Error(
                        "Error curating package '{0}.{1}' ({2} of {3}): {4}.",
                        package.Id,
                        package.Version,
                        processedCount,
                        totalCount,
                        ex.Message);
                }
            });
        }
Beispiel #12
0
        /// <summary>
        /// Imports the page.
        /// </summary>
        /// <param name="uploadedPackage">Byte array of the uploaded package</param>
        /// <param name="fileName">File name of uploaded package</param>
        /// <param name="personId">Id of the Person performing the import</param>
        /// <param name="pageId">The Id of the Page to save new data underneath</param>
        /// <param name="siteId">The Id of the Site tha the Page is being imported into</param>
        public bool ImportPage( byte[] uploadedPackage, string fileName, int personId, int pageId, int siteId )
        {
            // Write .nupkg file to the PackageStaging folder...
            var path = Path.Combine( HttpContext.Current.Server.MapPath( "~/App_Data/PackageStaging" ), fileName );
            using ( var file = new FileStream( path, FileMode.Create ) )
            {
                file.Write( uploadedPackage, 0, uploadedPackage.Length );
            }

            var package = new ZipPackage( path );
            var packageFiles = package.GetFiles().ToList();
            var exportFile = packageFiles.FirstOrDefault( f => f.Path.Contains( "export.json" ) );
            Page page = null;

            // If export.json is present, deserialize data
            // * Are there any new BlockTypes to register? If so, save them first.
            // * Scrub out any `Id` and `Guid` fields that came over from export
            // * Save page data via PageService

            if ( exportFile != null )
            {
                string json;

                using ( var stream = exportFile.GetStream() )
                {
                    json = stream.ReadToEnd();
                }

                page = Page.FromJson( json );
            }

            // Validate package...
            // + Does it have any executable .dll files? Should those go to the bin folder, or into a plugins directory to be loaded via MEF?
            // - Does it have code or asset files that need to go on the file system? (Done)
            // - Does it have an export.json file? Should that be a requirement? (Done)
            // + Does it have any corresponding SQL, migrations, seed methods to run, etc.

            if ( page != null )
            {
                // Find new block types and save them prior to scrubbing data...
                var newBlockTypes = FindNewBlockTypes( page, new BlockTypeService().Queryable() ).ToList();
                RockTransactionScope.WrapTransaction( () =>
                    {
                        try
                        {
                            var blockTypeService = new BlockTypeService();

                            foreach ( var blockType in newBlockTypes )
                            {
                                blockTypeService.Add( blockType, personId );
                                blockTypeService.Save( blockType, personId );
                            }

                            ValidateImportData( page, newBlockTypes );
                            SavePages( page, newBlockTypes, personId, pageId, siteId );
                            ExpandFiles( packageFiles );
                        }
                        catch ( Exception e )
                        {
                            ErrorMessages.Add( e.Message );
                        }
                    });

                // Clean up PackageStaging folder on successful import.
                var file = new FileInfo( path );
                file.Delete();
                return ErrorMessages.Count <= 0;
            }

            ErrorMessages.Add( "The export package uploaded does not appear to have any data associated with it." );
            return false;
        }
Beispiel #13
0
        //
        // ApplyReleases methods
        //
        List<string> installPackageToAppDir(UpdateInfo updateInfo, ReleaseEntry release)
        {
            var pkg = new ZipPackage(Path.Combine(rootAppDirectory, "packages", release.Filename));
            var target = getDirectoryForRelease(release.Version);

            // NB: This might happen if we got killed partially through applying the release
            if (target.Exists) {
                Utility.DeleteDirectory(target.FullName);
            }
            target.Create();

            // Copy all of the files out of the lib/ dirs in the NuGet package
            // into our target App directory.
            //
            // NB: We sort this list in order to guarantee that if a Net20
            // and a Net40 version of a DLL get shipped, we always end up
            // with the 4.0 version.
            pkg.GetFiles().Where(x => pathIsInFrameworkProfile(x, appFrameworkVersion)).OrderBy(x => x.Path)
                .ForEach(x => {
                    var targetPath = Path.Combine(target.FullName, Path.GetFileName(x.Path));

                    var fi = fileSystem.GetFileInfo(targetPath);
                    if (fi.Exists) fi.Delete();

                    using (var inf = x.GetStream())
                    using (var of = fi.Open(FileMode.CreateNew, FileAccess.Write)) {
                        log.Info("Writing {0} to app directory", targetPath);
                        inf.CopyTo(of);
                    }
                });

            var newCurrentVersion = updateInfo.FutureReleaseEntry.Version;

            // Perform post-install; clean up the previous version by asking it
            // which shortcuts to install, and nuking them. Then, run the app's
            // post install and set up shortcuts.
            return runPostInstallAndCleanup(newCurrentVersion, updateInfo.IsBootstrapping);
        }
Beispiel #14
0
        public IPackage ExplodeTo(string directory)
        {
            var explodedDirectory = ExplodedDirectory(directory);

            RippleLog.Info("Exploding to " + explodedDirectory);

            var fileSystem = new FileSystem();
            fileSystem.CreateDirectory(explodedDirectory);
            fileSystem.ForceClean(explodedDirectory);

            var package = new ZipPackage(_path);

            package.GetFiles().Each(file =>
            {
                var target = explodedDirectory.AppendPath(file.Path);
                fileSystem.CreateDirectory(target.ParentDirectory());

                using (var stream = new FileStream(target, FileMode.Create, FileAccess.Write))
                {
                    file.GetStream().CopyTo(stream);
                }
            });

            fileSystem.CopyToDirectory(_path, explodedDirectory);

            fileSystem.DeleteFile(_path);

            var newFile = Path.Combine(explodedDirectory, Path.GetFileName(_path));
            return new ZipPackage(newFile);
        }
Beispiel #15
0
        private void ProcessSymbolFile(IPackageFile symbolFile, ZipPackage package)
        {
            var tempSymbolFilePath = ExtractToSymbols(package, symbolFile);

            try
            {
                var referencedSources = symbolTools.GetSources(tempSymbolFilePath).ToList();

                var sourceFiles = new HashSet<string>(package.GetFiles("src").Select(f => f.Path.ToLowerInvariant()).ToList());
                if (referencedSources.Any() && sourceFiles.Any())
                {
                    var basePath = FindSourceBasePath(sourceFiles, referencedSources);

                    if (basePath.Length != 0)
                        symbolTools.MapSources(package, tempSymbolFilePath, referencedSources, r => r.Substring(basePath.Length));
                }
            }
            finally
            {
                File.Delete(tempSymbolFilePath);
            }
        }
Beispiel #16
0
 private static bool IsSymbolPackage(ZipPackage package, IEnumerable<IPackageFile> symbolFiles)
 {
     return symbolFiles.Any() && package.GetFiles("src").Any();
 }
Beispiel #17
0
        public static Assembly TryLoadHelp(this Assembly assembly, ZipPackage zipPackage, ILogger logger)
        {
            logger.LogInformation("Looking for xml help for {0}", assembly.Name);
            var helpFile = zipPackage.GetFiles().FirstOrDefault(file => file.Path.Equals(assembly.Path.Replace("dll", "xml"), StringComparison.OrdinalIgnoreCase));

            if (helpFile != null) {
                logger.LogInformation("Found xml help for {0}", assembly.Name);
                var xml = XDocument.Load(helpFile.GetStream());
                foreach (var member in xml.Element("doc").Element("members").Elements("member")) {
                    var name = member.Attribute("name")?.Value;
                    if (name == null) {
                        continue;
                    }

                    try {
                        switch (name.First()) {
                            case 'T': {
                                assembly.FindType(name.Substring(2))?.LoadHelp(member);
                                break;
                            }

                            case 'M': {
                                var argStart = name.IndexOf('(');
                                if (argStart < 2) {
                                    continue;
                                }
                                var methodName = name.Substring(2, argStart - 2);
                                var typeName = methodName.Substring(0, methodName.LastIndexOf('.'));
                                methodName = methodName.Substring(methodName.LastIndexOf('.') + 1);
                                assembly.FindType(typeName)?.Methods.FirstOrDefault(m => m.Name == methodName)?.LoadHelp(member);
                                break;
                            }
                        }
                    } catch (Exception ex) {
                        logger.LogError("Failed to pull out help details", ex);
                    }
                }
            }

            return assembly;
        }