Skip to content

Commit

Permalink
Move projects that target netcoreapp2.1 to netcoreapp3.1 (#4402)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkolev92 authored Jan 28, 2022
1 parent 0ca13df commit d619bad
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build/common.project.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<NETFXTargetFrameworkVersion>v4.7.2</NETFXTargetFrameworkVersion>
<NETFXTargetFramework>net472</NETFXTargetFramework>
<NETCoreTargetFramework>netcoreapp2.1</NETCoreTargetFramework>
<NETCoreTargetFramework>netcoreapp3.1</NETCoreTargetFramework>
<NETCoreTargetFramework Condition="'$(DotNetBuildFromSource)' == 'true'">net6.0</NETCoreTargetFramework>
<NETCoreTestTargetFramework>netcoreapp5.0</NETCoreTestTargetFramework>
<NetStandardVersion>netstandard2.0</NetStandardVersion>
Expand Down
4 changes: 2 additions & 2 deletions build/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion scripts/funcTests/runFuncTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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!!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<WebException>(exception.InnerException);
Expand All @@ -122,7 +115,7 @@ public async Task HttpRetryHandler_HandlesInvalidProtocol()
var exception = await ThrowsException<HttpRequestException>(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);
Expand All @@ -146,23 +139,23 @@ 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);
#endif
}
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);
#endif
}
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public static IEnumerable<object[]> 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) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,13 @@ public void SearchTree_InvalidSearchInput_Throws(string packagePatterns, string
var exception = Assert.Throws<ArgumentException>(
() => 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public void Build_WhenCertificateIsNull_Throws()
}
}

#if NET5_0_OR_GREATER || IS_DESKTOP
[Fact]
public void Build_WhenArgumentsAreValid_ReturnsExpectedResult()
{
Expand All @@ -62,5 +63,6 @@ public void Build_WhenArgumentsAreValid_ReturnsExpectedResult()
Assert.Equal(X509ChainStatusFlags.UntrustedRoot, chain.ChainStatus[0].Status);
}
}
#endif
}
}

0 comments on commit d619bad

Please sign in to comment.