Inheritance: IPackageMetadata, IValidatableObject
コード例 #1
0
ファイル: Manifest.cs プロジェクト: yonglehou/cli-1
        public static Manifest Create(PackageBuilder copy)
        {
            var metadata = new ManifestMetadata();
            metadata.Id = copy.Id?.Trim();
            metadata.Version = copy.Version;
            metadata.Title = copy.Title?.Trim();
            metadata.Authors = copy.Authors.Distinct();
            metadata.Owners = copy.Owners.Distinct();
            metadata.Tags = string.Join(",", copy.Tags).Trim();
            metadata.LicenseUrl = copy.LicenseUrl;
            metadata.ProjectUrl = copy.ProjectUrl;
            metadata.IconUrl = copy.IconUrl;
            metadata.RequireLicenseAcceptance = copy.RequireLicenseAcceptance;
            metadata.Description = copy.Description?.Trim();
            metadata.Copyright = copy.Copyright?.Trim();
            metadata.Summary = copy.Summary?.Trim();
            metadata.ReleaseNotes = copy.ReleaseNotes?.Trim();
            metadata.Language = copy.Language?.Trim();
            metadata.DependencySets = copy.DependencySets;
            metadata.FrameworkAssemblies = copy.FrameworkAssemblies;
            metadata.PackageAssemblyReferences = copy.PackageAssemblyReferences;
            metadata.MinClientVersionString = copy.MinClientVersion?.ToString();

            return new Manifest(metadata);
        }
コード例 #2
0
        private static int GetMaxVersionFromMetadata(ManifestMetadata metadata)
        {
            // Important: check for version 5 before version 4
            bool referencesHasTargetFramework =
              metadata.ReferenceSets != null &&
              metadata.ReferenceSets.Any(r => r.TargetFramework != null);

            if (referencesHasTargetFramework)
            {
                return TargetFrameworkSupportForReferencesVersion;
            }

            bool dependencyHasTargetFramework =
                metadata.DependencySets != null &&
                metadata.DependencySets.Any(d => d.TargetFramework != null);
            if (dependencyHasTargetFramework)
            {
                return TargetFrameworkSupportForDependencyContentsAndToolsVersion;
            }

            SemanticVersion semanticVersion;
            if (SemanticVersion.TryParse(metadata.Version, out semanticVersion) && !String.IsNullOrEmpty(semanticVersion.SpecialVersion))
            {
                return SemverVersion;
            }

            return DefaultVersion;
        }
コード例 #3
0
ファイル: ManifestReader.cs プロジェクト: leloulight/dnx
        private static ManifestMetadata ReadMetadata(XElement xElement)
        {
            var manifestMetadata = new ManifestMetadata();
            manifestMetadata.MinClientVersionString = (string)xElement.Attribute("minClientVersion");

            // we store all child elements under <metadata> so that we can easily check for required elements.
            var allElements = new HashSet<string>();

            foreach (var element in xElement.Elements())
            {
                ReadMetadataValue(manifestMetadata, element, allElements);
            }

            // now check for required elements, which include <id>, <version>, <authors> and <description>
            foreach (var requiredElement in RequiredElements)
            {
                if (!allElements.Contains(requiredElement))
                {
                    throw new InvalidDataException(
                        string.Format(CultureInfo.CurrentCulture, NuGetResources.Manifest_RequiredElementMissing, requiredElement));
                }
            }

            return manifestMetadata;
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: ledgarl/Samples
        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();
        }
コード例 #5
0
        public void OwnersFallbackToAuthors()
        {
            var metadata = new ManifestMetadata();
            metadata.Authors = new string[] { "A", "B" };

            Assert.Equal(new string[] { "A", "B" }, metadata.Owners);
        }
コード例 #6
0
        private static ManifestMetadata ReadMetadata(XElement xElement)
        {
            var manifestMetadata = new ManifestMetadata();
            manifestMetadata.DependencySets = new List<ManifestDependencySet>();
            manifestMetadata.ReferenceSets = new List<ManifestReferenceSet>();
            manifestMetadata.MinClientVersionString = xElement.GetOptionalAttributeValue("minClientVersion");

            // we store all child elements under <metadata> so that we can easily check for required elements.
            var allElements = new HashSet<string>();

            XNode node = xElement.FirstNode;
            while (node != null)
            {
                var element = node as XElement;
                if (element != null)
                {
                    ReadMetadataValue(manifestMetadata, element, allElements);
                }
                node = node.NextNode;
            }

            // now check for required elements, which include <id>, <version>, <authors> and <description>
            foreach (var requiredElement in RequiredElements)
            {
                if (!allElements.Contains(requiredElement))
                {
                    throw new InvalidDataException(
                        String.Format(CultureInfo.CurrentCulture, NuGetResources.Manifest_RequiredElementMissing, requiredElement));
                }
            }

            return manifestMetadata;
        }
コード例 #7
0
        private static int GetMaxVersionFromMetadata(ManifestMetadata metadata)
        {
            // Important: check for version 5 before version 4
            bool referencesHasTargetFramework =
              metadata.PackageAssemblyReferences != null &&
              metadata.PackageAssemblyReferences.Any(r => r.TargetFramework != null);

            if (referencesHasTargetFramework)
            {
                return TargetFrameworkSupportForReferencesVersion;
            }

            bool dependencyHasTargetFramework =
                metadata.DependencySets != null &&
                metadata.DependencySets.Any(d => d.TargetFramework != null);

            if (dependencyHasTargetFramework)
            {
                return TargetFrameworkSupportForDependencyContentsAndToolsVersion;
            }

            if (metadata.Version.IsPrerelease)
            {
                return SemverVersion;
            }

            return DefaultVersion;
        }
コード例 #8
0
        public IPackage CreatePackage(
            string packageId,
            string packageVersion,
            string contentFilePath,
            License requiresLicenseAccept,
            params IPackage[] dependencies)
        {
            PackageBuilder builder = new PackageBuilder();
            ManifestMetadata metadata = new ManifestMetadata()
            {
                Authors = "dummy author",
                Version = new SemanticVersion(packageVersion).ToString(),
                Id = packageId,
                Description = "dummy description",
                LicenseUrl = "http://choosealicense.com/",
                RequireLicenseAcceptance = (requiresLicenseAccept == License.Required)
            };

            List<ManifestDependency> dependencyList = new List<ManifestDependency>();
            foreach (IPackage dependencyNode in dependencies)
            {
                dependencyList.Add(new ManifestDependency()
                {
                    Id = dependencyNode.Id,
                    Version = dependencyNode.Version.ToString(),
                });
            }

            List<ManifestDependencySet> dependencySetList = new List<ManifestDependencySet>()
            {
                new ManifestDependencySet()
                {
                    Dependencies = dependencyList
                }
            };
            metadata.DependencySets = dependencySetList;

            builder.Populate(metadata);

            PhysicalPackageFile file = new PhysicalPackageFile();
            file.SourcePath = contentFilePath;
            file.TargetPath = Path.GetFileName(contentFilePath);
            builder.Files.Add(file);

            string fileName = packageId + "." + metadata.Version + ".nupkg";
            string destinationName = Path.Combine(this.manager.LocalRepository.Source, fileName);

            using (Stream fileStream = File.Open(destinationName, FileMode.OpenOrCreate))
            {
                builder.Save(fileStream);
            }

            // Retrieve and return the newly-created package
            IPackage package = this.fakeRemoteRepo.FindPackage(packageId, new SemanticVersion(packageVersion));
            Assert.IsNotNull(package, "Test setup error: failed to create and retrieve a test package");

            return package;
        }
コード例 #9
0
ファイル: Manifest.cs プロジェクト: yonglehou/cli-1
        public Manifest(ManifestMetadata metadata)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException(nameof(metadata));
            }

            Metadata = metadata;
        }
コード例 #10
0
 private static int GetVersionPropertyVersion(ManifestMetadata metadata)
 {
     SemanticVersion semanticVersion;
     if (SemanticVersion.TryParse(metadata.Version, out semanticVersion) && !String.IsNullOrEmpty(semanticVersion.SpecialVersion))
     {
         return SemverVersion;
     }
     return DefaultVersion;
 }
コード例 #11
0
        /// <summary>
        /// Creates a NuGet package from this mock package spec and copies it into the
        /// specified repository path.
        /// </summary>
        /// <param name="buildPath"></param>
        /// <param name="repositoryPath"></param>
        public void CreatePackage(string buildPath, string repositoryPath)
        {
            NuGet.PackageBuilder   builder  = new NuGet.PackageBuilder();
            NuGet.ManifestMetadata metadata = new NuGet.ManifestMetadata
            {
                Authors        = "AdamsLair",
                Version        = this.name.Version.ToString(),
                Id             = this.name.Id,
                Description    = string.Format("Mock Package: {0} {1}", this.name.Id, this.name.Version),
                Tags           = string.Join(" ", this.tags),
                DependencySets = this.dependencySets.Select(pair => new NuGet.ManifestDependencySet()
                {
                    TargetFramework = pair.Key,
                    Dependencies    =
                        pair.Value
                        .Select(item => new NuGet.ManifestDependency {
                        Id = item.Id, Version = item.Version.ToString()
                    })
                        .ToList()
                }).ToList()
            };

            // Set up file contents metadata for the package
            List <NuGet.ManifestFile> fileMetadata = new List <NuGet.ManifestFile>();

            foreach (var pair in this.files)
            {
                fileMetadata.Add(new NuGet.ManifestFile {
                    Source = pair.Key, Target = pair.Value
                });
                this.CreateFile(buildPath, pair.Key);
            }

            // If we don't have files or dependencies, at least at one mock file so we
            // can create a package at all. This is useful for test cases where we're
            // not actually interested in package contents at all.
            if (this.files.Count == 0 && !this.dependencySets.SelectMany(pair => pair.Value).Any())
            {
                fileMetadata.Add(new NuGet.ManifestFile {
                    Source = "Empty.dll", Target = "lib"
                });
                this.CreateFile(buildPath, "Empty.dll");
            }

            builder.PopulateFiles(buildPath, fileMetadata);
            builder.Populate(metadata);

            string packageFileName = Path.Combine(
                repositoryPath,
                string.Format("{0}.{1}.nupkg", this.name.Id, this.name.Version));

            using (FileStream stream = File.Open(packageFileName, FileMode.Create))
            {
                builder.Save(stream);
            }
        }
コード例 #12
0
 public void BuildPackage(string baseUrl, ManifestMetadata metadata, ManifestFile[] files)
 {
     NuGet.PackageBuilder packageBuilder = new NuGet.PackageBuilder();
     packageBuilder.Populate(metadata);
     packageBuilder.PopulateFiles(baseUrl, files);
     var saveDir = Path.Combine(DEFAULT_PACKAGES_SAVE_PATH, packageBuilder.Id, packageBuilder.Version.ToString().Replace('.', '_'));
     Directory.CreateDirectory(saveDir);
     var saveStream = File.Create(Path.Combine(saveDir, packageBuilder.Id + ".nupkg"));
     packageBuilder.Save(saveStream);
 }
コード例 #13
0
ファイル: Manifest.cs プロジェクト: leloulight/dnx
        public Manifest(ManifestMetadata metadata, IEnumerable<ManifestFile> files)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException(nameof(metadata));
            }

            Metadata = metadata;

            Files = files?.ToList() ?? new List<ManifestFile>();
        }
コード例 #14
0
ファイル: PackageEdit.cs プロジェクト: joyhui/NuGet.Jobs
 public virtual void ApplyTo(ManifestMetadata metadata)
 {
     metadata.Title = Title;
     metadata.Authors = Authors;
     metadata.Copyright = Copyright;
     metadata.Description = Description;
     metadata.IconUrl = IconUrl;          
     metadata.LicenseUrl = LicenseUrl;          
     metadata.ProjectUrl = ProjectUrl;
     metadata.ReleaseNotes = ReleaseNotes;
     metadata.RequireLicenseAcceptance = RequiresLicenseAcceptance;
     metadata.Summary = Summary;
     metadata.Tags = Tags;
 }
コード例 #15
0
ファイル: Manifest.cs プロジェクト: lishibo/buildtools
        public Manifest(ManifestMetadata metadata, ICollection<ManifestFile> files)
        {

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

            Metadata = metadata;

            if (files != null)
            {
                Files = files;
            }
        }
コード例 #16
0
ファイル: ManifestReader.cs プロジェクト: xero-github/Nuget
        private static ManifestMetadata ReadMetadata(XElement xElement)
        {
            var manifestMetadata = new ManifestMetadata();

            XNode node = xElement.FirstNode;
            while (node != null)
            {
                var element = node as XElement;
                if (element != null)
                {
                    ReadMetadataValue(manifestMetadata, element);
                }
                node = node.NextNode;
            }

            return manifestMetadata;
        }
コード例 #17
0
        private static int GetVersionFromMetadata(ManifestMetadata metadata)
        {
            bool dependencyHasTargetFramework =
                metadata.DependencySets != null &&
                metadata.DependencySets.Any(d => d.TargetFramework != null);
            if (dependencyHasTargetFramework)
            {
                return TargetFrameworkSupportVersion;
            }

            SemanticVersion semanticVersion;
            if (SemanticVersion.TryParse(metadata.Version, out semanticVersion) && !String.IsNullOrEmpty(semanticVersion.SpecialVersion))
            {
                return SemverVersion;
            }

            return DefaultVersion;
        }
コード例 #18
0
ファイル: ManifestReader.cs プロジェクト: ebenoit/NuGet
        private static ManifestMetadata ReadMetadata(XElement xElement)
        {
            var manifestMetadata = new ManifestMetadata();
            manifestMetadata.DependencySets = new List<ManifestDependencySet>();
            manifestMetadata.ReferenceSets = new List<ManifestReferenceSet>();

            XNode node = xElement.FirstNode;
            while (node != null)
            {
                var element = node as XElement;
                if (element != null)
                {
                    ReadMetadataValue(manifestMetadata, element);
                }
                node = node.NextNode;
            }

            return manifestMetadata;
        }
コード例 #19
0
        public void BuildPackage(string basePath, IList<string> includes, ManifestMetadata metadata, string outFolder, bool overwrite)
        {
            var package = new PackageBuilder();

            package.PopulateFiles(basePath, includes.Select(i => new ManifestFile { Source = i }));
            package.Populate(metadata);

            var filename = metadata.Id + "." + metadata.Version + ".nupkg";
            var output = Path.Combine(outFolder, filename);

            if (fileSystem.FileExists(output) && !overwrite)
                throw new CommandException("The package file already exists and --overwrite was not specified");

            log.InfoFormat("Saving {0} to {1}...", filename, outFolder);

            fileSystem.EnsureDirectoryExists(outFolder);

            using (var outStream = fileSystem.OpenFile(output, FileMode.Create))
                package.Save(outStream);
        }
コード例 #20
0
        private static ManifestMetadata ReadMetadata(XElement xElement)
        {
            var manifestMetadata = new ManifestMetadata();
            manifestMetadata.DependencySets = new List<ManifestDependencySet>();
            manifestMetadata.ReferenceSets = new List<ManifestReferenceSet>();
            manifestMetadata.MinClientVersionString = xElement.GetOptionalAttributeValue("minClientVersion");

            XNode node = xElement.FirstNode;
            while (node != null)
            {
                var element = node as XElement;
                if (element != null)
                {
                    ReadMetadataValue(manifestMetadata, element);
                }
                node = node.NextNode;
            }

            return manifestMetadata;
        }
コード例 #21
0
ファイル: Creator.cs プロジェクト: talisker77/Package.Util
    private void LoadAdditionalMetadata(ManifestMetadata meta)
    {
      meta.Summary = NuspecDefinition.Summary;
      if (!string.IsNullOrEmpty(NuspecDefinition.Id))
        meta.Id = NuspecDefinition.Id;

      if (!string.IsNullOrEmpty(NuspecDefinition.Version))
      {
        meta.Version = NuspecDefinition.Version;
      }

      if (!string.IsNullOrEmpty(NuspecDefinition.Authors))
      {
        meta.Authors = NuspecDefinition.Authors;
      }

      if (!string.IsNullOrEmpty(NuspecDefinition.Description))
      {
        meta.Description = NuspecDefinition.Description;
      }
    }
コード例 #22
0
        public void BuildPackage(string basePath, IList<string> includes, ManifestMetadata metadata, string outFolder, bool overwrite)
        {
            var filename = metadata.Id + "." + metadata.Version + ".zip";
            var output = fileSystem.GetFullPath(Path.Combine(outFolder, filename));

            if (fileSystem.FileExists(output) && !overwrite)
                throw new CommandException("The package file already exists and --overwrite was not specified");

            log.InfoFormat("Saving {0} to {1}...", filename, outFolder);

            fileSystem.EnsureDirectoryExists(outFolder);

            var basePathLength = fileSystem.GetFullPath(basePath).Length;
            using (var stream = fileSystem.OpenFile(output, FileAccess.Write))
            using (var archive = new ZipArchive(stream, ZipArchiveMode.Create))
            {
                foreach (var pattern in includes)
                {
                    log.DebugFormat("Adding files from '{0}' matching pattern '{1}'", basePath, pattern);
                    foreach (var file in PathResolver.PerformWildcardSearch(basePath, pattern))
                    {
                        var fullFilePath = fileSystem.GetFullPath(file);
                        if (string.Equals(fullFilePath, output, StringComparison.InvariantCultureIgnoreCase))
                            continue;

                        var relativePath = fullFilePath.Substring(basePathLength).TrimStart('\\');
                        log.Debug("Adding file: " + relativePath);

                        var entry = archive.CreateEntry(relativePath, CompressionLevel.Optimal);
                        entry.LastWriteTime = new DateTimeOffset(new FileInfo(file).LastWriteTimeUtc);
                        using (var entryStream = entry.Open())
                        using (var sourceStream = File.OpenRead(file))
                        {
                            sourceStream.CopyTo(entryStream);
                        }
                    }
                }
            }
        }
コード例 #23
0
        public void BuildPackageTest()
        {
            Assert.False(File.Exists(Path.Combine(PackageBuilder.DEFAULT_PACKAGES_SAVE_PATH, "BuildPackageTest", "0_0_0_1", "BuildPackageTest.nupkg")), "Test package already exists");

            ManifestMetadata metadata = new ManifestMetadata
            {
                Id = "BuildPackageTest",
                Summary = "Summary",
                Description = "Description",
                Version = "0.0.0.1",
                Authors = "Michael,xUnit",
                Owners = "Michael,xUnit"
            };

            List<ManifestFile> manifestFiles = new List<ManifestFile>();
            manifestFiles.Add(new ManifestFile
            {
                Source = "dist/select.js",
                Target = "content/Scripts/oi.select"
            });
            manifestFiles.Add(new ManifestFile
            {
                Source = "dist/select.css",
                Target = "content/Content/oi.select"
            });

            try
            {
                IPackageBuilder pkgBuilder = ninject.Get<IPackageBuilder>();
                pkgBuilder.BuildPackage(Path.Combine(GitManager.DEFAULT_CLONE_ROOT, "oi.select"), metadata, manifestFiles.ToArray());
            }
            catch (Exception ex)
            {
                Assert.True(false, ex.Message);
            }

            Assert.True(File.Exists(Path.Combine(PackageBuilder.DEFAULT_PACKAGES_SAVE_PATH, "BuildPackageTest", "0_0_0_1", "BuildPackageTest.nupkg")), "Package file is missing");
        }
コード例 #24
0
ファイル: PackageFactory.cs プロジェクト: run00/TeamCity
        IPackage IPackageFactory.CreateFromProject(string nupecFile, string csprojFile, string buildConfiguration, bool includeBinOutput)
        {
            var projectReader = _projectReaderFactory.Create(csprojFile);
            var binDir = projectReader.GetBinPath(buildConfiguration);
            var assemblyName = projectReader.GetAssemblyName();
            var assemblyPath = _fileSystem.CombinePaths(binDir, assemblyName);
            var assemblyReader = _assemblyReaderFactory.Create(assemblyPath);

            var manifest = new ManifestMetadata()
            {
                Id = assemblyReader.GetPackageId(),
                Title = assemblyReader.GetPackageTitle(),
                Owners = assemblyReader.GetCompany(),
                Authors = assemblyReader.GetCompany(),
                Description = assemblyReader.GetDescription(),
                Copyright = assemblyReader.GetCopyright(),
                Version = assemblyReader.GetFileVersion()
            };

            var files = new List<ManifestFile>();
            foreach (var dll in _fileSystem.FindFiles(binDir, "*.dll", false))
                files.Add(new ManifestFile() { Source = dll, Target = @"lib\net40" });

            var packageBuilder = new PackageBuilder();
            packageBuilder.Populate(manifest);
            packageBuilder.PopulateFiles(string.Empty, files);

            var projDir = _fileSystem.GetDirectory(csprojFile);
            var packagefile = _fileSystem.CombinePaths(projDir, "packages.config");

            var packagePath = _fileSystem.ChangeFileExtension(csprojFile, "nupkg");
            using (var stream = _fileSystem.OpenWrite(packagePath))
            {
                packageBuilder.Save(stream);
            }

            return new ZipPackage(packagePath);
        }
コード例 #25
0
        public ManifestMetadata ReadRepositoryMetadata(string repoPath)
        {
            var packageDefinitionFilePath = Path.Combine(repoPath, "package.json");
            if (File.Exists(packageDefinitionFilePath))
            {
                ManifestMetadata resMetadata = new ManifestMetadata();

                dynamic packageDef = JsonConvert.DeserializeObject(File.ReadAllText(packageDefinitionFilePath));

                resMetadata.Authors = this.GetAuthors(packageDef);
                resMetadata.Owners = this.GetOwners(packageDef);
                resMetadata.Id = packageDef.name;
                resMetadata.Summary = "Summary";
                resMetadata.Description = "Description";
                resMetadata.Version = SemanticVersion.Parse(packageDef.version);

                return resMetadata;
            }
            else
            {
                throw new NotSupportedException("This Content Utils implementation supports 'package.json' files only.");
            }
        }
コード例 #26
0
        public void OWnersIsEmptyByDefault()
        {
            var metadata = new ManifestMetadata();

            Assert.Empty(metadata.Owners);
        }
コード例 #27
0
        public void AuthorsIsEmptyByDefault()
        {
            var metadata = new ManifestMetadata();

            Assert.Empty(metadata.Authors);
        }
コード例 #28
0
ファイル: PackageBuilder.cs プロジェクト: xero-github/Nuget
        public void Populate(ManifestMetadata manifestMetadata)
        {
            IPackageMetadata metadata = manifestMetadata;
            Id = metadata.Id;
            Version = metadata.Version;
            Title = metadata.Title;
            Authors.AddRange(metadata.Authors);
            Owners.AddRange(metadata.Owners);
            IconUrl = metadata.IconUrl;
            LicenseUrl = metadata.LicenseUrl;
            ProjectUrl = metadata.ProjectUrl;
            RequireLicenseAcceptance = metadata.RequireLicenseAcceptance;
            Description = metadata.Description;
            Summary = metadata.Summary;
            ReleaseNotes = metadata.ReleaseNotes;
            Language = metadata.Language;
            Copyright = metadata.Copyright;

            if (metadata.Tags != null)
            {
                Tags.AddRange(ParseTags(metadata.Tags));
            }

            Dependencies.AddRange(metadata.Dependencies);
            FrameworkReferences.AddRange(metadata.FrameworkAssemblies);
            if (manifestMetadata.References != null)
            {
                PackageAssemblyReferences.AddRange(manifestMetadata.References.Select(reference => reference.File));
            }
        }
コード例 #29
0
        private static void ReadMetadataValue(ManifestMetadata manifestMetadata, XElement element, HashSet <string> allElements)
        {
            if (element.Value == null)
            {
                return;
            }

            allElements.Add(element.Name.LocalName);

            string value = element.Value?.Trim();

            switch (element.Name.LocalName)
            {
            case "id":
                manifestMetadata.Id = value;
                break;

            case "version":
                manifestMetadata.Version = NuGetVersion.Parse(value);
                break;

            case "authors":
                manifestMetadata.Authors = value.Split(',').Select(a => a.Trim());
                break;

            case "owners":
                manifestMetadata.Owners = value.Split(',').Select(a => a.Trim());
                break;

            case "licenseUrl":
                manifestMetadata.LicenseUrl = new Uri(value);
                break;

            case "projectUrl":
                manifestMetadata.ProjectUrl = new Uri(value);
                break;

            case "iconUrl":
                manifestMetadata.IconUrl = new Uri(value);
                break;

            case "requireLicenseAcceptance":
                manifestMetadata.RequireLicenseAcceptance = XmlConvert.ToBoolean(value);
                break;

            case "developmentDependency":
                manifestMetadata.DevelopmentDependency = XmlConvert.ToBoolean(value);
                break;

            case "description":
                manifestMetadata.Description = value;
                break;

            case "summary":
                manifestMetadata.Summary = value;
                break;

            case "releaseNotes":
                manifestMetadata.ReleaseNotes = value;
                break;

            case "copyright":
                manifestMetadata.Copyright = value;
                break;

            case "language":
                manifestMetadata.Language = value;
                break;

            case "title":
                manifestMetadata.Title = value;
                break;

            case "tags":
                manifestMetadata.Tags = value;
                break;

            case "dependencies":
                manifestMetadata.DependencySets = ReadDependencySets(element);
                break;

            case "frameworkAssemblies":
                manifestMetadata.FrameworkAssemblies = ReadFrameworkAssemblies(element);
                break;

            case "references":
                manifestMetadata.PackageAssemblyReferences = ReadReferenceSets(element);
                break;

            case "contentFiles":
                manifestMetadata.ContentFiles = ReadContentFiles(element);
                break;
            }
        }
コード例 #30
0
 public Manifest()
 {
     Metadata = new ManifestMetadata();
 }
コード例 #31
0
ファイル: Manifest.cs プロジェクト: lishibo/buildtools
 public Manifest(ManifestMetadata metadata) : this(metadata, null)
 {
 }
コード例 #32
0
        private IPackage AddPackage(IPackageManager manager, string id, string version, string payloadAssemblyFilePath, params IPackage[] dependencies)
        {
            PackageBuilder builder = new PackageBuilder();

            ManifestMetadata metadata = new ManifestMetadata()
            {
                Authors = "dummy author 1,dummy author 2",
                Owners = "dummy owner 1,dummy owner 2",
                Title = "dummy title",
                Version = new SemanticVersion(version).ToString(),
                Id = id,
                Description = "dummy description",
                LicenseUrl = "http://my.license/readme.txt",
                ProjectUrl = "http://dummyurl/"
            };

            List<ManifestDependency> dependencyList = new List<ManifestDependency>();
            foreach (IPackage dependencyNode in dependencies)
            {
                dependencyList.Add(new ManifestDependency()
                {
                    Id = dependencyNode.Id,
                    Version = dependencyNode.Version.ToString(),
                });
            }

            List<ManifestDependencySet> dependencySetList = new List<ManifestDependencySet>()
            {
                new ManifestDependencySet()
                {
                    Dependencies = dependencyList
                }
            };
            metadata.DependencySets = dependencySetList;

            builder.Populate(metadata);

            PhysicalPackageFile file = new PhysicalPackageFile();
            file.SourcePath = payloadAssemblyFilePath;
            file.TargetPath = "analyzers/" + Path.GetFileName(payloadAssemblyFilePath);
            builder.Files.Add(file);

            using (MemoryStream stream = new MemoryStream())
            {
                builder.Save(stream);
                stream.Position = 0;

                ZipPackage pkg = new ZipPackage(stream);
                manager.InstallPackage(pkg, true, true);

                return pkg;
            }
        }
コード例 #33
0
        private static int GetMaxVersionFromMetadata(ManifestMetadata metadata)
        {
            SemanticVersion version;

            return(!((metadata.ReferenceSets != null) && Enumerable.Any <ManifestReferenceSet>(metadata.ReferenceSets, r => r.TargetFramework != null)) ? (!((metadata.DependencySets != null) && Enumerable.Any <ManifestDependencySet>(metadata.DependencySets, d => d.TargetFramework != null)) ? ((!SemanticVersion.TryParse(metadata.Version, out version) || string.IsNullOrEmpty(version.SpecialVersion)) ? 1 : 3) : 4) : 5);
        }
コード例 #34
0
 public static int GetManifestVersion(ManifestMetadata metadata)
 {
     return(Math.Max(VisitObject(metadata), GetVersionFromMetadata(metadata)));
 }
コード例 #35
0
ファイル: Manifest.cs プロジェクト: nagyistoce/dnx
 public Manifest()
 {
     Metadata = new ManifestMetadata();
 }
コード例 #36
0
ファイル: Manifest.cs プロジェクト: jkarthid/dotnet-cli
 public Manifest(ManifestMetadata metadata) : this(metadata, null)
 {
 }