|
1 | 1 | // Licensed to the .NET Foundation under one or more agreements.
|
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license.
|
3 | 3 |
|
4 |
| -//using Microsoft.DotNet.TestFramework; |
5 | 4 | using EndToEnd.Tests.Utilities;
|
6 |
| -using NuGet.ProjectModel; |
7 |
| -using NuGet.Versioning; |
8 |
| -//using RestoreCommand = Microsoft.DotNet.Tools.Test.Utilities.RestoreCommand; |
9 |
| -//using NewCommandShim = Microsoft.DotNet.Tools.Test.Utilities.NewCommandShim; |
10 |
| -//using TestBase = Microsoft.DotNet.Tools.Test.Utilities.TestBase; |
11 |
| -//using static Microsoft.DotNet.Tools.Test.Utilities.TestCommandExtensions; |
12 | 5 |
|
13 | 6 | namespace EndToEnd.Tests
|
14 | 7 | {
|
15 | 8 | public partial class GivenSelfContainedAppsRollForward(ITestOutputHelper log) : SdkTest(log)
|
16 | 9 | {
|
17 |
| - public const string NETCorePackageName = "Microsoft.NETCore.App"; |
18 |
| - public const string AspNetCoreAppPackageName = "Microsoft.AspNetCore.App"; |
19 |
| - public const string AspNetCoreAllPackageName = "Microsoft.AspNetCore.All"; |
20 |
| - |
21 |
| - [Theory] |
22 |
| - [ClassData(typeof(SupportedNetCoreAppVersions))] |
23 |
| - public void ItRollsForwardToTheLatestNetCoreVersion(string minorVersion) |
24 |
| - { |
25 |
| - ItRollsForwardToTheLatestVersion(NETCorePackageName, minorVersion); |
26 |
| - } |
27 |
| - |
28 |
| - [Theory] |
29 |
| - [ClassData(typeof(SupportedAspNetCoreVersions))] |
30 |
| - public void ItRollsForwardToTheLatestAspNetCoreAppVersion(string minorVersion) |
31 |
| - { |
32 |
| - ItRollsForwardToTheLatestVersion(AspNetCoreAppPackageName, minorVersion); |
33 |
| - } |
34 |
| - |
35 |
| - [Theory] |
36 |
| - [ClassData(typeof(SupportedAspNetCoreVersions))] |
37 |
| - public void ItRollsForwardToTheLatestAspNetCoreAllVersion(string minorVersion) |
38 |
| - { |
39 |
| - ItRollsForwardToTheLatestVersion(AspNetCoreAllPackageName, minorVersion); |
40 |
| - } |
41 |
| - |
42 |
| - internal void ItRollsForwardToTheLatestVersion(string packageName, string minorVersion) |
43 |
| - { |
44 |
| - var testProjectCreator = new TestProjectCreator() |
45 |
| - { |
46 |
| - PackageName = packageName, |
47 |
| - MinorVersion = minorVersion, |
48 |
| - // Set RuntimeIdentifier to opt in to roll-forward behavior |
49 |
| - RuntimeIdentifier = RuntimeInformation.RuntimeIdentifier |
50 |
| - }; |
51 |
| - |
52 |
| - var testInstance = testProjectCreator.Create(_testAssetsManager); |
53 |
| - |
54 |
| - // Get the version rolled forward to |
55 |
| - new RestoreCommand(testInstance) |
56 |
| - .Execute().Should().Pass(); |
57 |
| - |
58 |
| - string assetsFilePath = Path.Combine(testInstance.TestRoot, "obj", "project.assets.json"); |
59 |
| - var assetsFile = new LockFileFormat().Read(assetsFilePath); |
60 |
| - |
61 |
| - var rolledForwardVersion = GetPackageVersion(assetsFile, packageName); |
62 |
| - rolledForwardVersion.Should().NotBeNull(); |
63 |
| - |
64 |
| - if (rolledForwardVersion.IsPrerelease) |
65 |
| - { |
66 |
| - // If this version of .NET Core is still prerelease, then: |
67 |
| - // - Floating the patch by adding ".*" to the major.minor version won't work, but |
68 |
| - // - There aren't any patches to roll-forward to, so we skip testing this until the version |
69 |
| - // leaves prerelease. |
70 |
| - return; |
71 |
| - } |
72 |
| - |
73 |
| - testProjectCreator.Identifier = "floating"; |
74 |
| - |
75 |
| - var floatingProjectInstance = testProjectCreator.Create(_testAssetsManager); |
76 |
| - |
77 |
| - var floatingProjectPath = Path.Combine(floatingProjectInstance.TestRoot, "TestAppSimple.csproj"); |
78 |
| - |
79 |
| - var floatingProject = XDocument.Load(floatingProjectPath); |
80 |
| - var ns = floatingProject.Root.Name.Namespace; |
81 |
| - |
82 |
| - if (packageName == TestProjectCreator.NETCorePackageName) |
83 |
| - { |
84 |
| - // Float the RuntimeFrameworkVersion to get the latest version of the runtime available from feeds |
85 |
| - floatingProject.Root.Element(ns + "PropertyGroup") |
86 |
| - .Add(new XElement(ns + "RuntimeFrameworkVersion", $"{minorVersion}.*")); |
87 |
| - } |
88 |
| - else |
89 |
| - { |
90 |
| - floatingProject.Root.Element(ns + "ItemGroup") |
91 |
| - .Element(ns + "PackageReference") |
92 |
| - .Add(new XAttribute("Version", $"{minorVersion}.*"), |
93 |
| - new XAttribute("AllowExplicitVersion", "true")); |
94 |
| - } |
95 |
| - |
96 |
| - floatingProject.Save(floatingProjectPath); |
97 |
| - |
98 |
| - new RestoreCommand(floatingProjectInstance) |
99 |
| - .Execute().Should().Pass(); |
100 |
| - |
101 |
| - string floatingAssetsFilePath = Path.Combine(floatingProjectInstance.TestRoot, "obj", "project.assets.json"); |
102 |
| - |
103 |
| - var floatedAssetsFile = new LockFileFormat().Read(floatingAssetsFilePath); |
104 |
| - |
105 |
| - var floatedVersion = GetPackageVersion(floatedAssetsFile, packageName); |
106 |
| - floatedVersion.Should().NotBeNull(); |
107 |
| - |
108 |
| - rolledForwardVersion.ToNormalizedString().Should().BeEquivalentTo(floatedVersion.ToNormalizedString(), |
109 |
| - $"the latest patch version for {packageName} {minorVersion} in Microsoft.NETCoreSdk.BundledVersions.props " + |
110 |
| - "needs to be updated (see the ImplicitPackageVariable items in MSBuildExtensions.targets in this repo)"); |
111 |
| - } |
112 |
| - |
113 |
| - private static NuGetVersion GetPackageVersion(LockFile lockFile, string packageName) => lockFile?.Targets?.SingleOrDefault(t => t.RuntimeIdentifier != null) |
114 |
| - ?.Libraries?.SingleOrDefault(l => |
115 |
| - string.Compare(l.Name, packageName, StringComparison.CurrentCultureIgnoreCase) == 0) |
116 |
| - ?.Version; |
117 |
| - |
118 | 10 | [Fact]
|
119 | 11 | public void WeCoverLatestNetCoreAppRollForward()
|
120 | 12 | {
|
|
0 commit comments