Esempio n. 1
0
 private static List <ManifestDependency> CreateDependencies(ICollection <PackageDependency> dependencies) =>
 ((dependencies != null) ? Enumerable.Select <PackageDependency, ManifestDependency>(dependencies, delegate(PackageDependency dependency) {
     ManifestDependency dependency1 = new ManifestDependency();
     dependency1.Id = dependency.Id.SafeTrim();
     dependency1.Version = dependency.VersionSpec.ToStringSafe();
     return(dependency1);
 }).ToList <ManifestDependency>() : new List <ManifestDependency>(0));
Esempio n. 2
0
        static Manifest InitiateManifestFromAssembly(Assembly assembly, IEnumerable<PackageReference> deps){
            Manifest manifest = new Manifest();

            AssemblyInfo ainfo = new AssemblyInfo(assembly);

            //Version
            manifest.Metadata.Version = ManifestVersionFromAssembly(ainfo);

            // Copyright
            manifest.Metadata.Copyright = ainfo.Copyright;

            // Authors
            if (ainfo.Authors != null) {
                manifest.Metadata.Authors = ainfo.Authors.Keys.Aggregate((key, next) => key + "," + next);
                manifest.Metadata.Owners = ainfo.Authors.Keys.Aggregate((key, next) => key + "," + next);
            }

            // Description
            manifest.Metadata.Description = ainfo.Description;

            // Icon Url
            if ( ainfo.IconUrl != null )
                manifest.Metadata.IconUrl = ainfo.IconUrl.ToString();

            // Id
            manifest.Metadata.Id = ainfo.ProductTitle;

            // License Url
            if (ainfo.LicenseUrl != null)
                manifest.Metadata.LicenseUrl = ainfo.LicenseUrl.ToString();

            // Project Url
            if (ainfo.ProjectUrl != null)
                manifest.Metadata.ProjectUrl = ainfo.ProjectUrl.ToString();

            // Tags
            manifest.Metadata.Tags = ainfo.Tags;

            // Title
            manifest.Metadata.Title = ainfo.ProductTitle;

            // Dependencies
            if (deps != null) {
                manifest.Metadata.DependencySets = new List<ManifestDependencySet>();

                foreach (var frameworkVersion in deps.Select<PackageReference, FrameworkName>(pr => pr.TargetFramework).Distinct().ToArray()) {

                    NetPortableProfile npp = new NetPortableProfile("test", new FrameworkName[1]{ frameworkVersion });

                    ManifestDependencySet mds = new ManifestDependencySet();
                    mds.Dependencies = new List<ManifestDependency>();
                    mds.TargetFramework = npp.CustomProfileString;

                    manifest.Metadata.DependencySets.Add(mds);
                    foreach (var dep in deps.Where(d => d.TargetFramework == frameworkVersion).ToArray()) {

                        ManifestDependency md = new ManifestDependency();
                        md.Id = dep.Id;
                        md.Version = dep.Version.ToNormalizedString();

                        mds.Dependencies.Add(md);


                    }
                }
            }

            return manifest;
        }