From d619bad07de3e7c3ae08efabae2319c44e17088d Mon Sep 17 00:00:00 2001 From: Nikolche Kolev Date: Fri, 28 Jan 2022 08:44:05 -0800 Subject: [PATCH] Move projects that target netcoreapp2.1 to netcoreapp3.1 (#4402) --- build/common.project.props | 2 +- build/common.ps1 | 4 ++-- scripts/funcTests/runFuncTests.sh | 2 +- .../HttpRetryHandlerTests.cs | 15 ++++----------- .../NuGet.Common.Test/DateTimeUtilityTests.cs | 2 +- .../NuGet.Configuration.Test/SearchTreeTest.cs | 8 +++++++- .../DefaultX509ChainBuildPolicyTests.cs | 2 ++ 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/build/common.project.props b/build/common.project.props index 4b96e1198d2..2dae6391a63 100644 --- a/build/common.project.props +++ b/build/common.project.props @@ -14,7 +14,7 @@ PackageReference v4.7.2 net472 - netcoreapp2.1 + netcoreapp3.1 net6.0 netcoreapp5.0 netstandard2.0 diff --git a/build/common.ps1 b/build/common.ps1 index f1aaf4e6f81..241d849f6d7 100644 --- a/build/common.ps1 +++ b/build/common.ps1 @@ -277,11 +277,11 @@ Function Install-DotnetCLI { } # Install the 2.x runtime because our tests target netcoreapp2x - Trace-Log "$DotNetInstall -Runtime dotnet -Channel 2.2 -InstallDir $CLIRoot -NoPath" + Trace-Log "$DotNetInstall -Runtime dotnet -Channel 3.1 -InstallDir $CLIRoot -NoPath" # dotnet-install might make http requests that fail, but it handles those errors internally # However, Invoke-BuildStep checks if any error happened, ever. Hence we need to run dotnet-install # in a different process, to avoid treating their handled errors as build errors. - & powershell $DotNetInstall -Runtime dotnet -Channel 2.2 -InstallDir $CLIRoot -NoPath + & powershell $DotNetInstall -Runtime dotnet -Channel 3.1 -InstallDir $CLIRoot -NoPath if ($LASTEXITCODE -ne 0) { throw "dotnet-install.ps1 exited with non-zero exit code" diff --git a/scripts/funcTests/runFuncTests.sh b/scripts/funcTests/runFuncTests.sh index 1435c93b9aa..43fdde3589e 100755 --- a/scripts/funcTests/runFuncTests.sh +++ b/scripts/funcTests/runFuncTests.sh @@ -36,7 +36,7 @@ curl -o cli/dotnet-install.sh -L https://dot.net/v1/dotnet-install.sh chmod +x cli/dotnet-install.sh # Get recommended version for bootstrapping testing version -cli/dotnet-install.sh -i cli -c 2.2 -nopath +cli/dotnet-install.sh -i cli -c 3.1 -nopath if (( $? )); then echo "The .NET CLI Install failed!!" diff --git a/test/NuGet.Core.FuncTests/NuGet.Protocol.FuncTest/HttpRetryHandlerTests.cs b/test/NuGet.Core.FuncTests/NuGet.Protocol.FuncTest/HttpRetryHandlerTests.cs index c0f83599bcd..1190b910388 100644 --- a/test/NuGet.Core.FuncTests/NuGet.Protocol.FuncTest/HttpRetryHandlerTests.cs +++ b/test/NuGet.Core.FuncTests/NuGet.Protocol.FuncTest/HttpRetryHandlerTests.cs @@ -2,13 +2,10 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; -using System.Linq; using System.Net; using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using FluentAssertions; using NuGet.Common; using NuGet.Protocol; using NuGet.Test.Server; @@ -100,11 +97,7 @@ public async Task HttpRetryHandler_HandlesFailureToConnect() } else { -#if (NETCORE3_0 || NETCORE5_0) Assert.Equal("No connection could be made because the target machine actively refused it.", exception.InnerException.Message); -#else - Assert.Equal("No connection could be made because the target machine actively refused it", exception.InnerException.Message); -#endif } #else var innerException = Assert.IsType(exception.InnerException); @@ -122,7 +115,7 @@ public async Task HttpRetryHandler_HandlesInvalidProtocol() var exception = await ThrowsException(server); #if IS_CORECLR Assert.Null(exception.InnerException); -#if (NETCORE3_0 || NETCORE5_0) +#if NETCOREAPP3_1_OR_GREATER Assert.Equal("Received an invalid status code: 'BAD'.", exception.Message); #else Assert.Equal("The server returned an invalid or unrecognized response.", exception.Message); @@ -146,7 +139,7 @@ public async Task HttpRetryHandler_HandlesNameResolutionFailure() if (RuntimeEnvironmentHelper.IsMacOSX) { -#if (NETCORE3_0 || NETCORE5_0) +#if NETCOREAPP3_1_OR_GREATER Assert.Equal("nodename nor servname provided, or not known", exception.InnerException.Message); #else Assert.Equal("Device not configured", exception.InnerException.Message); @@ -154,7 +147,7 @@ public async Task HttpRetryHandler_HandlesNameResolutionFailure() } else if (!RuntimeEnvironmentHelper.IsWindows) { -#if (NETCORE3_0 || NETCORE5_0) +#if NETCOREAPP3_1_OR_GREATER Assert.Equal("Name or service not known", exception.InnerException.Message); #else Assert.Equal("No such device or address", exception.InnerException.Message); @@ -162,7 +155,7 @@ public async Task HttpRetryHandler_HandlesNameResolutionFailure() } else { -#if (NETCORE3_0 || NETCORE5_0) +#if NETCOREAPP3_1_OR_GREATER Assert.Equal("No such host is known.", exception.InnerException.Message); #else Assert.Equal("No such host is known", exception.InnerException.Message); diff --git a/test/NuGet.Core.Tests/NuGet.Common.Test/DateTimeUtilityTests.cs b/test/NuGet.Core.Tests/NuGet.Common.Test/DateTimeUtilityTests.cs index 78c6951b1e4..a86f0d42249 100644 --- a/test/NuGet.Core.Tests/NuGet.Common.Test/DateTimeUtilityTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Common.Test/DateTimeUtilityTests.cs @@ -16,8 +16,8 @@ public static IEnumerable GetData() { new object[] { "1.23", TimeSpan.FromSeconds(1.23d) }, new object[] { "0", TimeSpan.FromMilliseconds(0.01d) }, // round down - new object[] { "1", TimeSpan.FromMilliseconds(0.56d) }, // round up new object[] { "1", TimeSpan.FromMilliseconds(1.21d) }, // round down + new object[] { "1", TimeSpan.FromMilliseconds(0.96d) }, // round up new object[] { "92183.91", TimeSpan.FromHours(92183.91d) }, new object[] { "1", TimeSpan.FromSeconds(3600.0d) }, new object[] { "3.6", TimeSpan.FromMinutes(3.6d) }, diff --git a/test/NuGet.Core.Tests/NuGet.Configuration.Test/SearchTreeTest.cs b/test/NuGet.Core.Tests/NuGet.Configuration.Test/SearchTreeTest.cs index e392657766f..748b7147fdb 100644 --- a/test/NuGet.Core.Tests/NuGet.Configuration.Test/SearchTreeTest.cs +++ b/test/NuGet.Core.Tests/NuGet.Configuration.Test/SearchTreeTest.cs @@ -213,7 +213,13 @@ public void SearchTree_InvalidSearchInput_Throws(string packagePatterns, string var exception = Assert.Throws( () => configuration.GetConfiguredPackageSources(term)); - Assert.Equal("Argument cannot be null, empty, or whitespace only." + Environment.NewLine + "Parameter name: term", exception.Message); +#if NETCOREAPP + var expectedLine = "Argument cannot be null, empty, or whitespace only. (Parameter 'term')"; +#else + var expectedLine = "Argument cannot be null, empty, or whitespace only." + Environment.NewLine + "Parameter name: term"; +#endif + + Assert.Equal(expectedLine, exception.Message); } private SearchTree GetSearchTree(string packagePatterns) diff --git a/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/ChainBuilding/DefaultX509ChainBuildPolicyTests.cs b/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/ChainBuilding/DefaultX509ChainBuildPolicyTests.cs index cae92da1c58..2e9a01e35e6 100644 --- a/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/ChainBuilding/DefaultX509ChainBuildPolicyTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/ChainBuilding/DefaultX509ChainBuildPolicyTests.cs @@ -50,6 +50,7 @@ public void Build_WhenCertificateIsNull_Throws() } } +#if NET5_0_OR_GREATER || IS_DESKTOP [Fact] public void Build_WhenArgumentsAreValid_ReturnsExpectedResult() { @@ -62,5 +63,6 @@ public void Build_WhenArgumentsAreValid_ReturnsExpectedResult() Assert.Equal(X509ChainStatusFlags.UntrustedRoot, chain.ChainStatus[0].Status); } } +#endif } }