示例#1
0
        public void FrameworkListListsContainsCorrectPaths()
        {
            if (!_isTargetingPackBuilding || string.IsNullOrEmpty(Environment.GetEnvironmentVariable("helix")))
            {
                return;
            }

            var frameworkListPath = Path.Combine(_targetingPackRoot, "data", "FrameworkList.xml");

            AssertEx.FileExists(frameworkListPath);

            var frameworkListDoc     = XDocument.Load(frameworkListPath);
            var frameworkListEntries = frameworkListDoc.Root.Descendants();

            var targetingPackPath = Path.Combine(Environment.GetEnvironmentVariable("HELIX_WORKITEM_ROOT"), ("Microsoft.AspNetCore.App.Ref." + TestData.GetSharedFxVersion() + ".nupkg"));

            ZipArchive archive = ZipFile.OpenRead(targetingPackPath);

            var actualPaths = archive.Entries
                              .Where(i => i.FullName.EndsWith(".dll"))
                              .Select(i => i.FullName).ToHashSet();

            var expectedPaths = frameworkListEntries.Select(i => i.Attribute("Path").Value).ToHashSet();

            _output.WriteLine("==== package contents ====");
            _output.WriteLine(string.Join('\n', actualPaths.OrderBy(i => i)));
            _output.WriteLine("==== expected assemblies ====");
            _output.WriteLine(string.Join('\n', expectedPaths.OrderBy(i => i)));

            var missing    = expectedPaths.Except(actualPaths);
            var unexpected = actualPaths.Except(expectedPaths);

            _output.WriteLine("==== missing assemblies from the runtime list ====");
            _output.WriteLine(string.Join('\n', missing));
            _output.WriteLine("==== unexpected assemblies in the runtime list ====");
            _output.WriteLine(string.Join('\n', unexpected));

            Assert.Empty(missing);
            Assert.Empty(unexpected);
        }
示例#2
0
        public void PlatformManifestListsAllFiles()
        {
            if (!_isTargetingPackBuilding)
            {
                return;
            }

            var platformManifestPath = Path.Combine(_targetingPackRoot, "data", "PlatformManifest.txt");
            var expectedAssemblies   = TestData.GetSharedFxDependencies()
                                       .Split(';', StringSplitOptions.RemoveEmptyEntries)
                                       .Select(i =>
            {
                var fileName = Path.GetFileName(i);
                return(fileName.EndsWith(".dll", StringComparison.Ordinal)
                        ? fileName.Substring(0, fileName.Length - 4)
                        : fileName);
            })
                                       .ToHashSet();

            _output.WriteLine("==== file contents ====");
            _output.WriteLine(File.ReadAllText(platformManifestPath));
            _output.WriteLine("==== expected assemblies ====");
            _output.WriteLine(string.Join('\n', expectedAssemblies.OrderBy(i => i)));

            AssertEx.FileExists(platformManifestPath);

            var manifestFileLines = File.ReadAllLines(platformManifestPath);

            var actualAssemblies = manifestFileLines
                                   .Where(s => !string.IsNullOrEmpty(s))
                                   .Select(i =>
            {
                var fileName = i.Split('|')[0];
                return(fileName.EndsWith(".dll", StringComparison.Ordinal)
                        ? fileName.Substring(0, fileName.Length - 4)
                        : fileName);
            })
                                   .ToHashSet();

            if (!TestData.VerifyAncmBinary())
            {
                actualAssemblies.Remove("aspnetcorev2_inprocess");
                expectedAssemblies.Remove("aspnetcorev2_inprocess");
            }

            var missing    = expectedAssemblies.Except(actualAssemblies);
            var unexpected = actualAssemblies.Except(expectedAssemblies);

            _output.WriteLine("==== missing assemblies from the manifest ====");
            _output.WriteLine(string.Join('\n', missing));
            _output.WriteLine("==== unexpected assemblies in the manifest ====");
            _output.WriteLine(string.Join('\n', unexpected));

            Assert.Empty(missing);
            Assert.Empty(unexpected);

            Assert.All(manifestFileLines, line =>
            {
                var parts = line.Split('|');
                Assert.Equal(4, parts.Length);
                Assert.Equal("Microsoft.AspNetCore.App.Ref", parts[1]);
                if (parts[2].Length > 0)
                {
                    Assert.True(Version.TryParse(parts[2], out _), "Assembly version must be convertable to System.Version");
                }
                Assert.True(Version.TryParse(parts[3], out _), "File version must be convertable to System.Version");
            });
        }
示例#3
0
        public void PackageOverridesContainsCorrectEntries()
        {
            if (!_isTargetingPackBuilding)
            {
                return;
            }

            var packageOverridePath = Path.Combine(_targetingPackRoot, "data", "PackageOverrides.txt");

            AssertEx.FileExists(packageOverridePath);

            var packageOverrideFileLines = File.ReadAllLines(packageOverridePath);
            var runtimeDependencies      = TestData.GetRuntimeTargetingPackDependencies()
                                           .Split(';', StringSplitOptions.RemoveEmptyEntries)
                                           .ToHashSet();
            var aspnetcoreDependencies = TestData.GetAspNetCoreTargetingPackDependencies()
                                         .Split(';', StringSplitOptions.RemoveEmptyEntries)
                                         .ToHashSet();

            Assert.Equal(packageOverrideFileLines.Length, runtimeDependencies.Count + aspnetcoreDependencies.Count);

            // PackageOverrides versions should remain at Major.Minor.0 while servicing.
            var netCoreAppPackageVersion = TestData.GetMicrosoftNETCoreAppPackageVersion();

            Assert.True(
                NuGetVersion.TryParse(netCoreAppPackageVersion, out var parsedVersion),
                "MicrosoftNETCoreAppPackageVersion must be convertable to a NuGetVersion.");
            if (parsedVersion.Patch != 0 && !parsedVersion.IsPrerelease)
            {
                netCoreAppPackageVersion = $"{parsedVersion.Major}.{parsedVersion.Minor}.0";
            }

            var aspNetCoreAppPackageVersion = TestData.GetReferencePackSharedFxVersion();

            Assert.True(
                NuGetVersion.TryParse(aspNetCoreAppPackageVersion, out parsedVersion),
                "ReferencePackSharedFxVersion must be convertable to a NuGetVersion.");
            if (parsedVersion.Patch != 0 && !parsedVersion.IsPrerelease)
            {
                aspNetCoreAppPackageVersion = $"{parsedVersion.Major}.{parsedVersion.Minor}.0";
            }

            Assert.All(packageOverrideFileLines, entry =>
            {
                var packageOverrideParts = entry.Split("|");
                Assert.Equal(2, packageOverrideParts.Length);

                var packageName    = packageOverrideParts[0];
                var packageVersion = packageOverrideParts[1];

                if (runtimeDependencies.Contains(packageName))
                {
                    Assert.Equal(netCoreAppPackageVersion, packageVersion);
                }
                else if (aspnetcoreDependencies.Contains(packageName))
                {
                    Assert.Equal(aspNetCoreAppPackageVersion, packageVersion);
                }
                else
                {
                    Assert.True(false, $"{packageName} is not a recognized aspNetCore or runtime dependency");
                }
            });
        }
示例#4
0
        public void RuntimeListListsContainsCorrectPaths()
        {
            var runtimePath = Environment.GetEnvironmentVariable("ASPNET_RUNTIME_PATH");

            if (string.IsNullOrEmpty(runtimePath))
            {
                return;
            }

            var runtimeListPath = Path.Combine(_sharedFxRoot, "RuntimeList.xml");

            AssertEx.FileExists(runtimeListPath);

            var runtimeListDoc     = XDocument.Load(runtimeListPath);
            var runtimeListEntries = runtimeListDoc.Root.Descendants();

            var sharedFxPath = Path.Combine(Environment.GetEnvironmentVariable("HELIX_WORKITEM_ROOT"), ("Microsoft.AspNetCore.App.Runtime.win-x64." + TestData.GetSharedFxVersion() + ".nupkg"));

            ZipArchive archive = ZipFile.OpenRead(sharedFxPath);

            var actualPaths = archive.Entries
                              .Where(i => i.FullName.EndsWith(".dll", StringComparison.Ordinal))
                              .Select(i => i.FullName).ToHashSet();

            var expectedPaths = runtimeListEntries.Select(i => i.Attribute("Path").Value).ToHashSet();

            _output.WriteLine("==== package contents ====");
            _output.WriteLine(string.Join('\n', actualPaths.OrderBy(i => i)));
            _output.WriteLine("==== expected assemblies ====");
            _output.WriteLine(string.Join('\n', expectedPaths.OrderBy(i => i)));

            var missing    = expectedPaths.Except(actualPaths);
            var unexpected = actualPaths.Except(expectedPaths);

            _output.WriteLine("==== missing assemblies from the runtime list ====");
            _output.WriteLine(string.Join('\n', missing));
            _output.WriteLine("==== unexpected assemblies in the runtime list ====");
            _output.WriteLine(string.Join('\n', unexpected));

            Assert.Empty(missing);
            Assert.Empty(unexpected);
        }
示例#5
0
 public SharedFxTests(ITestOutputHelper output)
 {
     _output       = output;
     _expectedTfm  = TestData.GetDefaultNetCoreTargetFramework();
     _expectedRid  = TestData.GetSharedFxRuntimeIdentifier();
     _sharedFxRoot = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNET_RUNTIME_PATH"))
         ? Path.Combine(TestData.GetTestDataValue("SharedFrameworkLayoutRoot"), "shared", "Microsoft.AspNetCore.App", TestData.GetTestDataValue("RuntimePackageVersion"))
         : Environment.GetEnvironmentVariable("ASPNET_RUNTIME_PATH");
     _expectedVersionFileName = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNET_RUNTIME_PATH"))
         ? ".version"
         : "Microsoft.AspNetCore.App.versions.txt";
 }
示例#6
0
 public SharedFxTests(ITestOutputHelper output)
 {
     _output       = output;
     _expectedTfm  = "netcoreapp" + TestData.GetSharedFxVersion().Substring(0, 3);
     _expectedRid  = TestData.GetSharedFxRuntimeIdentifier();
     _sharedFxRoot = Path.Combine(TestData.GetTestDataValue("SharedFrameworkLayoutRoot"), "shared", "Microsoft.AspNetCore.App", TestData.GetTestDataValue("RuntimePackageVersion"));
 }