Exemple #1
0
        public void compose_dependencies()
        {
            TestAsset simpleDependenciesAsset = _testAssetsManager
                                                .CopyTestAsset("SimpleCache")
                                                .WithSource();

            ComposeCache cacheCommand = new ComposeCache(Stage0MSBuild, simpleDependenciesAsset.TestRoot, "SimpleCache.xml");

            var OutputFolder = Path.Combine(simpleDependenciesAsset.TestRoot, "outdir");
            var WorkingDir   = Path.Combine(simpleDependenciesAsset.TestRoot, "w");

            cacheCommand
            .Execute($"/p:RuntimeIdentifier={_runtimeRid}", $"/p:TargetFramework={_tfm}", $"/p:ComposeDir={OutputFolder}", $"/p:ComposeWorkingDir={WorkingDir}", "/p:DoNotDecorateComposeDir=true", "/p:PreserveComposeWorkingDir=true")
            .Should()
            .Pass();
            DirectoryInfo cacheDirectory = new DirectoryInfo(OutputFolder);

            List <string> files_on_disk = new List <string> {
                "artifact.xml",
                $"runtime.{_runtimeRid}.microsoft.netcore.coredistools/1.0.1-prerelease-00001/runtimes/{_runtimeRid}/native/{_libPrefix}coredistools{Constants.DynamicLibSuffix}",
                $"runtime.{_runtimeRid}.microsoft.netcore.coredistools/1.0.1-prerelease-00001/runtimes/{_runtimeRid}/native/coredistools.h"
            };

            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && _testArch != "x86")
            {
                files_on_disk.Add($"runtime.{_runtimeRid}.runtime.native.system/4.4.0-beta-24821-02/runtimes/{_runtimeRid}/native/System.Native.a");
                files_on_disk.Add($"runtime.{_runtimeRid}.runtime.native.system/4.4.0-beta-24821-02/runtimes/{_runtimeRid}/native/System.Native{Constants.DynamicLibSuffix}");
            }
            cacheDirectory.Should().OnlyHaveFiles(files_on_disk);

            //valid artifact.xml
            var knownpackage = new HashSet <PackageIdentity>();

            knownpackage.Add(new PackageIdentity("Microsoft.NETCore.Targets", NuGetVersion.Parse("1.2.0-beta-24821-02")));
            knownpackage.Add(new PackageIdentity("System.Private.Uri", NuGetVersion.Parse("4.4.0-beta-24821-02")));
            knownpackage.Add(new PackageIdentity("Microsoft.NETCore.CoreDisTools", NuGetVersion.Parse("1.0.1-prerelease-00001")));
            knownpackage.Add(new PackageIdentity($"runtime.{_runtimeOs}.System.Private.Uri", NuGetVersion.Parse("4.4.0-beta-24821-02")));
            knownpackage.Add(new PackageIdentity("Microsoft.NETCore.Platforms", NuGetVersion.Parse("1.2.0-beta-24821-02")));
            knownpackage.Add(new PackageIdentity($"runtime.{_runtimeRid}.Microsoft.NETCore.CoreDisTools", NuGetVersion.Parse("1.0.1-prerelease-00001")));

            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && _testArch != "x86")
            {
                knownpackage.Add(new PackageIdentity("runtime.native.System", NuGetVersion.Parse("4.4.0-beta-24821-02")));
                knownpackage.Add(new PackageIdentity($"runtime.{_runtimeRid}.runtime.native.System", NuGetVersion.Parse("4.4.0-beta-24821-02")));
            }

            var artifact         = Path.Combine(OutputFolder, "artifact.xml");
            var packagescomposed = CacheArtifactParser.Parse(artifact);

            packagescomposed.Count.Should().Be(knownpackage.Count);

            foreach (var pkg in packagescomposed)
            {
                knownpackage.Should().Contain(elem => elem.Equals(pkg), "package {0}, version {1} was not expected to be cached", pkg.Id, pkg.Version);
            }
        }
Exemple #2
0
        public void compose_multifile()
        {
            TestAsset simpleDependenciesAsset = _testAssetsManager
                                                .CopyTestAsset("ProfileLists")
                                                .WithSource();

            ComposeCache cacheCommand = new ComposeCache(Stage0MSBuild, simpleDependenciesAsset.TestRoot, "NewtonsoftFilterProfile.xml");

            var OutputFolder   = Path.Combine(simpleDependenciesAsset.TestRoot, "o");
            var WorkingDir     = Path.Combine(simpleDependenciesAsset.TestRoot, "w");
            var additonalproj1 = Path.Combine(simpleDependenciesAsset.TestRoot, "NewtonsoftMultipleVersions.xml");
            var additonalproj2 = Path.Combine(simpleDependenciesAsset.TestRoot, "FluentAssertions.xml");

            cacheCommand
            .Execute($"/p:RuntimeIdentifier={_runtimeRid}", $"/p:TargetFramework={_tfm}", $"/p:Additionalprojects={additonalproj1}%3b{additonalproj2}", $"/p:ComposeDir={OutputFolder}", $"/p:ComposeWorkingDir={WorkingDir}", "/p:DoNotDecorateComposeDir=true")
            .Should()
            .Pass();
            DirectoryInfo cacheDirectory = new DirectoryInfo(OutputFolder);

            List <string> files_on_disk = new List <string> {
                "artifact.xml",
                @"newtonsoft.json/9.0.2-beta2/lib/netstandard1.1/Newtonsoft.Json.dll",
                @"newtonsoft.json/9.0.1/lib/netstandard1.0/Newtonsoft.Json.dll",
                @"fluentassertions.json/4.12.0/lib/netstandard1.3/FluentAssertions.Json.dll"
            };

            cacheDirectory.Should().HaveFiles(files_on_disk);

            var knownpackage = new HashSet <PackageIdentity>();

            knownpackage.Add(new PackageIdentity("Newtonsoft.Json", NuGetVersion.Parse("9.0.1")));
            knownpackage.Add(new PackageIdentity("Newtonsoft.Json", NuGetVersion.Parse("9.0.2-beta2")));
            knownpackage.Add(new PackageIdentity("FluentAssertions.Json", NuGetVersion.Parse("4.12.0")));

            var artifact         = Path.Combine(OutputFolder, "artifact.xml");
            var packagescomposed = CacheArtifactParser.Parse(artifact);

            packagescomposed.Count.Should().BeGreaterThan(0);

            foreach (var pkg in knownpackage)
            {
                packagescomposed.Should().Contain(elem => elem.Equals(pkg), "package {0}, version {1} was not expected to be cached", pkg.Id, pkg.Version);
            }
        }