private IEnumerable <RuntimeLibrary> GetRuntimePackLibraries()
        {
            if (_runtimePackAssets == null)
            {
                return(Enumerable.Empty <RuntimeLibrary>());
            }
            return(_runtimePackAssets.Select(runtimePack =>
            {
                var runtimeAssemblyGroup = new RuntimeAssetGroup(string.Empty,
                                                                 runtimePack.Value.Where(asset => asset.AssetType == AssetType.Runtime)
                                                                 .Select(asset => CreateRuntimeFile(asset.DestinationSubPath, asset.SourcePath)));

                var nativeLibraryGroup = new RuntimeAssetGroup(string.Empty,
                                                               runtimePack.Value.Where(asset => asset.AssetType == AssetType.Native)
                                                               .Select(asset => CreateRuntimeFile(asset.DestinationSubPath, asset.SourcePath)));

                return new RuntimeLibrary(
                    type: "runtimepack",
                    name: runtimePack.Key,
                    version: runtimePack.Value.First().PackageVersion,
                    hash: string.Empty,
                    runtimeAssemblyGroups: new[] { runtimeAssemblyGroup },
                    nativeLibraryGroups: new[] { nativeLibraryGroup },
                    resourceAssemblies: Enumerable.Empty <ResourceAssembly>(),
                    dependencies: Enumerable.Empty <Dependency>(),
                    serviceable: false);
            }));
        }
        public void WritesRuntimeTargetForNonPortableLegacy()
        {
            var group      = new RuntimeAssetGroup(string.Empty, "Banana.dll");
            var assetGroup = WritesRuntimeTarget(group);

            var files = assetGroup.Should().HavePropertyAsObject("runtime").Subject;

            files.Should().HaveProperty("Banana.dll");
        }
        public void WritesRuntimeLibrariesToRuntimeTargetWithAssemblyVersions()
        {
            RuntimeFile[] runtimeFile = { new RuntimeFile("Banana.Win7-x64.dll", "1.2.3", "7.8.9") };
            var           group       = new RuntimeAssetGroup("win7-x64", runtimeFile);

            var runtimeAssembly = WritesRuntimeLibrariesToRuntimeTargetCore(group);

            runtimeAssembly.Should().HavePropertyValue("assemblyVersion", "1.2.3");
            runtimeAssembly.Should().HavePropertyValue("fileVersion", "7.8.9");
        }
        public void WritesRuntimeTargetForNonPortable()
        {
            RuntimeFile[] runtimeFiles = { new RuntimeFile("Banana.dll", "1.2.3", "7.8.9") };
            var           group        = new RuntimeAssetGroup(string.Empty, runtimeFiles);
            var           assetGroup   = WritesRuntimeTarget(group);

            var files = assetGroup.Should().HavePropertyAsObject("runtime").Subject;
            var file  = files.Should().HavePropertyAsObject("Banana.dll").Subject;

            file.Should().HavePropertyValue("assemblyVersion", "1.2.3");
            file.Should().HavePropertyValue("fileVersion", "7.8.9");
        }
        private JObject WritesRuntimeTarget(RuntimeAssetGroup group)
        {
            var result = Save(Create(
                                  "Target",
                                  "runtime",
                                  false,
                                  runtimeLibraries: new[]
            {
                new RuntimeLibrary(
                    "package",
                    "PackageName",
                    "1.2.3",
                    "HASH",
                    new [] {
                    group
                },
                    new [] {
                    new RuntimeAssetGroup(string.Empty, "runtimes\\osx\\native\\native.dylib")
                },
                    new ResourceAssembly[] {},
                    new [] {
                    new Dependency("Fruits.Abstract.dll", "2.0.0")
                },
                    true,
                    "PackagePath",
                    "PackageHashPath"
                    ),
            }));

            // targets
            var targets      = result.Should().HavePropertyAsObject("targets").Subject;
            var target       = targets.Should().HavePropertyAsObject("Target/runtime").Subject;
            var assetGroup   = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
            var dependencies = assetGroup.Should().HavePropertyAsObject("dependencies").Subject;

            dependencies.Should().HavePropertyValue("Fruits.Abstract.dll", "2.0.0");
            assetGroup.Should().HavePropertyAsObject("native")
            .Subject.Should().HaveProperty("runtimes/osx/native/native.dylib");

            //libraries
            var libraries = result.Should().HavePropertyAsObject("libraries").Subject;
            var library   = libraries.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;

            library.Should().HavePropertyValue("sha512", "HASH");
            library.Should().HavePropertyValue("type", "package");
            library.Should().HavePropertyValue("serviceable", true);
            library.Should().HavePropertyValue("path", "PackagePath");
            library.Should().HavePropertyValue("hashPath", "PackageHashPath");

            return(assetGroup);
        }
Exemplo n.º 6
0
        private static IEnumerable <string> SelectAssets(IEnumerable <string> rids, IEnumerable <RuntimeAssetGroup> groups)
        {
            foreach (string rid in rids)
            {
                RuntimeAssetGroup group = groups.FirstOrDefault(g => g.Runtime == rid);
                if (group != null)
                {
                    return(group.AssetPaths);
                }
            }

            // Return the RID-agnostic group
            return(groups.GetDefaultAssets());
        }
        private JObject WritesRuntimeLibrariesToRuntimeTargetCore(RuntimeAssetGroup group)
        {
            var result = Save(Create(
                                  "Target",
                                  "runtime",
                                  true,
                                  runtimeLibraries: new[]
            {
                new RuntimeLibrary(
                    "package",
                    "PackageName",
                    "1.2.3",
                    "HASH",
                    new [] {
                    new RuntimeAssetGroup(string.Empty, "Banana.dll"),
                    group
                },
                    new [] {
                    new RuntimeAssetGroup(string.Empty, "runtimes\\linux\\native\\native.so"),
                    new RuntimeAssetGroup("win7-x64", "native\\Banana.Win7-x64.so")
                },
                    new [] { new ResourceAssembly("en-US\\Banana.Resource.dll", "en-US") },
                    new [] {
                    new Dependency("Fruits.Abstract.dll", "2.0.0")
                },
                    true,
                    "PackagePath",
                    "PackageHashPath",
                    "placeHolderManifest.xml"
                    ),
            }));

            // targets
            var targets      = result.Should().HavePropertyAsObject("targets").Subject;
            var target       = targets.Should().HavePropertyAsObject("Target").Subject;
            var library      = target.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
            var dependencies = library.Should().HavePropertyAsObject("dependencies").Subject;

            dependencies.Should().HavePropertyValue("Fruits.Abstract.dll", "2.0.0");

            library.Should().HavePropertyAsObject("runtime")
            .Subject.Should().HaveProperty("Banana.dll");
            library.Should().HavePropertyAsObject("native")
            .Subject.Should().HaveProperty("runtimes/linux/native/native.so");

            var runtimeTargets = library.Should().HavePropertyAsObject("runtimeTargets").Subject;

            var runtimeAssembly = runtimeTargets.Should().HavePropertyAsObject("Banana.Win7-x64.dll").Subject;

            runtimeAssembly.Should().HavePropertyValue("rid", "win7-x64");
            runtimeAssembly.Should().HavePropertyValue("assetType", "runtime");

            var nativeLibrary = runtimeTargets.Should().HavePropertyAsObject("native/Banana.Win7-x64.so").Subject;

            nativeLibrary.Should().HavePropertyValue("rid", "win7-x64");
            nativeLibrary.Should().HavePropertyValue("assetType", "native");

            var resourceAssemblies = library.Should().HavePropertyAsObject("resources").Subject;
            var resourceAssembly   = resourceAssemblies.Should().HavePropertyAsObject("en-US/Banana.Resource.dll").Subject;

            resourceAssembly.Should().HavePropertyValue("locale", "en-US");

            //libraries
            var libraries = result.Should().HavePropertyAsObject("libraries").Subject;

            library = libraries.Should().HavePropertyAsObject("PackageName/1.2.3").Subject;
            library.Should().HavePropertyValue("sha512", "HASH");
            library.Should().HavePropertyValue("type", "package");
            library.Should().HavePropertyValue("serviceable", true);
            library.Should().HavePropertyValue("path", "PackagePath");
            library.Should().HavePropertyValue("hashPath", "PackageHashPath");
            library.Should().HavePropertyValue("runtimeStoreManifestName", "placeHolderManifest.xml");

            return(runtimeAssembly);
        }
        public void WritesRuntimeLibrariesToRuntimeTarget()
        {
            var group = new RuntimeAssetGroup("win7-x64", "Banana.Win7-x64.dll");

            WritesRuntimeLibrariesToRuntimeTargetCore(group);
        }