Skip to content

Commit

Permalink
update SDK to .NET 8 (#2462)
Browse files Browse the repository at this point in the history
* [build] Bump .NET SDK: 7.0.401->8.0.100

* Fix tests after migration to .NET 8

* [build] Force cake to use our .NET SDK

* [build] Bump Cake.Frosting: 3.0.0->3.2.0

* [build] Fix PATH setting in build.ps1

---------

Co-authored-by: Andrey Akinshin <andrey.akinshin@gmail.com>
  • Loading branch information
adamsitnik and AndreyAkinshin authored Nov 15, 2023
1 parent 1b39e8e commit e903115
Show file tree
Hide file tree
Showing 28 changed files with 52 additions and 46 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ jobs:
- uses: actions/checkout@v3
- name: Run task 'build'
shell: cmd
run: |
./build.cmd build
run: ./build.cmd build
- name: Run task 'in-tests-core'
shell: cmd
run: |
./build.cmd in-tests-core -e
run: ./build.cmd in-tests-core -e
- name: Upload test results
uses: actions/upload-artifact@v3
if: always()
Expand All @@ -42,12 +40,10 @@ jobs:
- uses: actions/checkout@v3
- name: Run task 'build'
shell: cmd
run: |
./build.cmd build
run: ./build.cmd build
- name: Run task 'in-tests-full'
shell: cmd
run: |
./build.cmd in-tests-full -e
run: ./build.cmd in-tests-full -e
- name: Upload test results
uses: actions/upload-artifact@v3
if: always()
Expand Down
4 changes: 2 additions & 2 deletions build/BenchmarkDotNet.Build/BenchmarkDotNet.Build.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Cake.Frosting" Version="3.0.0" />
<PackageReference Include="Cake.Frosting" Version="3.2.0" />
<PackageReference Include="Cake.FileHelpers" Version="6.1.3" />
<PackageReference Include="Cake.Git" Version="3.0.0" />
<PackageReference Include="Docfx.App" Version="2.71.1" />
Expand Down
3 changes: 3 additions & 0 deletions build/BenchmarkDotNet.Build/BuildContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public BuildContext(ICakeContext context)
BuildDirectory = RootDirectory.Combine("build");
ArtifactsDirectory = RootDirectory.Combine("artifacts");

var toolFileName = context.IsRunningOnWindows() ? "dotnet.exe" : "dotnet";
var toolFilePath = RootDirectory.Combine(".dotnet").CombineWithFilePath(toolFileName);
context.Tools.RegisterFile(toolFilePath);

SolutionFile = RootDirectory.CombineWithFilePath("BenchmarkDotNet.sln");

Expand Down
2 changes: 1 addition & 1 deletion build/BenchmarkDotNet.Build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public class InTestsFullTask : FrostingTask<BuildContext>, IHelpProvider
public class InTestsCoreTask : FrostingTask<BuildContext>, IHelpProvider
{
private const string Name = "in-tests-core";
public override void Run(BuildContext context) => context.UnitTestRunner.RunInTests("net7.0");
public override void Run(BuildContext context) => context.UnitTestRunner.RunInTests("net8.0");
public HelpInfo GetHelp() => new();
}

Expand Down
3 changes: 2 additions & 1 deletion build/BenchmarkDotNet.Build/Runners/BuildRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public void Restore()
context.DotNetRestore(context.SolutionFile.FullPath,
new DotNetRestoreSettings
{
MSBuildSettings = context.MsBuildSettingsRestore
MSBuildSettings = context.MsBuildSettingsRestore,
Verbosity = DotNetVerbosity.Normal
});
}

Expand Down
4 changes: 2 additions & 2 deletions build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ private void RunTests(FilePath projectFile, string alias, string tfm)
public void RunUnitTests()
{
var targetFrameworks = context.IsRunningOnWindows()
? new[] { "net462", "net7.0" }
: new[] { "net7.0" };
? new[] { "net462", "net8.0" }
: new[] { "net8.0" };

foreach (var targetFramework in targetFrameworks)
RunUnitTests(targetFramework);
Expand Down
5 changes: 2 additions & 3 deletions build/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ if (!(Test-Path $InstallPath)) {
$ScriptPath = Join-Path $InstallPath 'dotnet-install.ps1'
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, $ScriptPath);
& $ScriptPath -JSonFile $GlobalJsonPath -InstallDir $InstallPath;

Remove-PathVariable "$InstallPath"
$env:PATH = "$InstallPath;$env:PATH"
}

Remove-PathVariable "$InstallPath"
$env:PATH = "$InstallPath;$env:PATH"
$env:DOTNET_ROOT=$InstallPath

###########################################################################
Expand Down
2 changes: 1 addition & 1 deletion build/sdk/global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.401",
"version": "8.0.100",
"rollForward": "disable"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net462;net7.0</TargetFrameworks>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<AssemblyTitle>BenchmarkDotNet.Samples</AssemblyTitle>
<TargetFrameworks>net7.0;net462</TargetFrameworks>
<TargetFrameworks>net8.0;net462</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>BenchmarkDotNet.Samples</AssemblyName>
<OutputType>Exe</OutputType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<AssemblyTitle>BenchmarkDotNet.IntegrationTests.ConfigPerAssembly</AssemblyTitle>
<TargetFrameworks>net462;net7.0</TargetFrameworks>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>BenchmarkDotNet.IntegrationTests.ConfigPerAssembly</AssemblyName>
<PackageId>BenchmarkDotNet.IntegrationTests.ConfigPerAssembly</PackageId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<AssemblyTitle>BenchmarkDotNet.IntegrationTests.DisabledOptimizations</AssemblyTitle>
<TargetFrameworks>net462;net7.0</TargetFrameworks>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>BenchmarkDotNet.IntegrationTests.DisabledOptimizations</AssemblyName>
<PackageId>BenchmarkDotNet.IntegrationTests.DisabledOptimizations</PackageId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<AssemblyTitle>BenchmarkDotNet.IntegrationTests.EnabledOptimizations</AssemblyTitle>
<TargetFrameworks>net462;net7.0</TargetFrameworks>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>BenchmarkDotNet.IntegrationTests.EnabledOptimizations</AssemblyName>
<PackageId>BenchmarkDotNet.IntegrationTests.EnabledOptimizations</PackageId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFrameworks>net462;net7.0</TargetFrameworks>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
<PublicSign>false</PublicSign>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<AssemblyTitle>BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks</AssemblyTitle>
<!-- We test the oldest frameworks supported by BDN (net461 and netcoreapp2.0), as well as newer versions of those frameworks. -->
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworks>net461;net48;netcoreapp2.0;net7.0</TargetFrameworks>
<TargetFrameworks>net461;net48;netcoreapp2.0;net8.0</TargetFrameworks>
<NoWarn>$(NoWarn);NU1903</NoWarn> <!-- NU1903: Package 'Microsoft.NETCore.App' 2.0.0 has a known high severity vulnerability -->
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<AssemblyTitle>BenchmarkDotNet.IntegrationTests.ManualRunning</AssemblyTitle>
<TargetFrameworks>net462;net7.0</TargetFrameworks>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>BenchmarkDotNet.IntegrationTests.ManualRunning</AssemblyName>
<PackageId>BenchmarkDotNet.IntegrationTests.ManualRunning</PackageId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<AssemblyTitle>BenchmarkDotNet.IntegrationTests.Static</AssemblyTitle>
<TargetFrameworks>net462;net7.0</TargetFrameworks>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>BenchmarkDotNet.IntegrationTests.Static</AssemblyName>
<PackageId>BenchmarkDotNet.IntegrationTests.Static</PackageId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFrameworks>net462;net7.0</TargetFrameworks>
<TargetFrameworks>net462;net8.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\BenchmarkDotNet\BenchmarkDotNet.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<AssemblyTitle>BenchmarkDotNet.IntegrationTests</AssemblyTitle>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">net462;net7.0</TargetFrameworks>
<TargetFramework Condition="'$(OS)' != 'Windows_NT'">net7.0</TargetFramework>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">net462;net8.0</TargetFrameworks>
<TargetFramework Condition="'$(OS)' != 'Windows_NT'">net8.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>BenchmarkDotNet.IntegrationTests</AssemblyName>
<PackageId>BenchmarkDotNet.IntegrationTests</PackageId>
Expand Down
6 changes: 3 additions & 3 deletions tests/BenchmarkDotNet.IntegrationTests/BuildTimeoutTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public void WhenBuildTakesMoreTimeThanTheTimeoutTheBuildIsCancelled()
var config = ManualConfig.CreateEmpty()
.WithBuildTimeout(timeout)
.AddJob(Job.Dry
.WithRuntime(NativeAotRuntime.Net70)
.WithRuntime(NativeAotRuntime.Net80)
.WithToolchain(NativeAotToolchain.CreateBuilder()
.UseNuGet("7.0.0", "https://api.nuget.org/v3/index.json")
.TargetFrameworkMoniker("net7.0")
.UseNuGet("8.0.0", "https://api.nuget.org/v3/index.json")
.TargetFrameworkMoniker("net8.0")
.ToToolchain()));

var summary = CanExecute<NativeAotBenchmark>(config, fullValidation: false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public static IEnumerable<object[]> GetAllJits()
{
if (RuntimeInformation.GetCurrentPlatform() is Platform.X86 or Platform.X64)
{
yield return new object[] { Jit.RyuJit, Platform.X64, CoreRuntime.Core70 }; // .NET Core x64
yield return new object[] { Jit.RyuJit, Platform.X64, CoreRuntime.Core80 }; // .NET Core x64
}
else if (RuntimeInformation.GetCurrentPlatform() is Platform.Arm64 && RuntimeInformation.IsLinux())
{
yield return new object[] { Jit.RyuJit, Platform.Arm64, CoreRuntime.Core70 }; // .NET Core arm64
yield return new object[] { Jit.RyuJit, Platform.Arm64, CoreRuntime.Core80 }; // .NET Core arm64
}
}
if (RuntimeInformation.IsMacOS())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static IEnumerable<object[]> CheckCore_Arguments()
[MemberData(nameof(CheckCore_Arguments))]
public void CheckCore(Jit jit, Platform platform, string errorMessage)
{
Verify(CoreRuntime.Core70, jit, platform, errorMessage);
Verify(CoreRuntime.Core80, jit, platform, errorMessage);
}

private void Verify(Runtime runtime, Jit jit, Platform platform, string errorMessage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void BenchmarkCanAllocateMoreThan2Gb()
.Any());

Assert.Contains(".NET Framework", summary.AllRuntimes);
Assert.Contains(".NET 7.0", summary.AllRuntimes);
Assert.Contains(".NET 8.0", summary.AllRuntimes);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ public void MemoryDiagnoserSupportsNativeAOT()
.ToToolchain());
}

[FactEnvSpecific("We don't want to test MonoVM twice (for .NET Framework 4.6.2 and .NET 7.0)", EnvRequirement.DotNetCoreOnly)]
[FactEnvSpecific("We don't want to test MonoVM twice (for .NET Framework 4.6.2 and .NET 8.0)", EnvRequirement.DotNetCoreOnly)]
public void MemoryDiagnoserSupportsModernMono()
{
MemoryDiagnoserIsAccurate(MonoToolchain.Mono70);
MemoryDiagnoserIsAccurate(MonoToolchain.Mono80);
}

public class AllocatingGlobalSetupAndCleanup
Expand Down
15 changes: 11 additions & 4 deletions tests/BenchmarkDotNet.IntegrationTests/MonoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Portability;
using BenchmarkDotNet.Tests.Loggers;
using BenchmarkDotNet.Tests.XUnit;
using Xunit.Abstractions;

namespace BenchmarkDotNet.IntegrationTests
{
public class MonoTests : BenchmarkTestExecutor
{
public MonoTests(ITestOutputHelper output) : base(output) { }

[FactEnvSpecific("UseMonoRuntime option is available in .NET Core only starting from .NET 6", EnvRequirement.DotNetCoreOnly)]
public void Mono70IsSupported()
public void Mono80IsSupported()
{
var config = ManualConfig.CreateEmpty().AddJob(Job.Dry.WithRuntime(MonoRuntime.Mono70));
var logger = new OutputLogger(Output);
var config = ManualConfig.CreateEmpty()
.AddLogger(logger)
.AddJob(Job.Dry.WithRuntime(MonoRuntime.Mono80));
CanExecute<MonoBenchmark>(config);
}

Expand All @@ -27,11 +34,11 @@ public void Check()
throw new Exception("This is not Mono runtime");
}

if (RuntimeInformation.GetCurrentRuntime() != MonoRuntime.Mono70)
if (RuntimeInformation.GetCurrentRuntime() != MonoRuntime.Mono80)
{
throw new Exception("Incorrect runtime detection");
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void SingleBenchmarkCanBeExecutedForMultipleRuntimes()
.Any());

Assert.Contains(".NET Framework", summary.AllRuntimes);
Assert.Contains(".NET 7.0", summary.AllRuntimes);
Assert.Contains(".NET 8.0", summary.AllRuntimes);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<AssemblyTitle>BenchmarkDotNet.Tests</AssemblyTitle>
<TargetFrameworks>net7.0;net462</TargetFrameworks>
<TargetFrameworks>net8.0;net462</TargetFrameworks>
<AssemblyName>BenchmarkDotNet.Tests</AssemblyName>
<PackageId>BenchmarkDotNet.Tests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
Expand Down
2 changes: 1 addition & 1 deletion tests/BenchmarkDotNet.Tests/ConfigParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public void SpecifyingCoreRunWithFullFrameworkTargetsMostRecentTfm()
[FactEnvSpecific("It's impossible to determine TFM for CoreRunToolchain if host process is not .NET (Core) process", EnvRequirement.DotNetCoreOnly)]
public void SpecifyingCoreRunAndRuntimeCreatesTwoJobs()
{
const string runtime = "net7.0";
const string runtime = "net8.0";
var fakeDotnetCliPath = typeof(object).Assembly.Location;
var fakeCoreRunPath = typeof(ConfigParserTests).Assembly.Location;
var fakeRestorePackages = Path.GetTempPath();
Expand Down

0 comments on commit e903115

Please sign in to comment.