Skip to content

Commit e903115

Browse files
update SDK to .NET 8 (#2462)
* [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 <[email protected]>
1 parent 1b39e8e commit e903115

File tree

28 files changed

+52
-46
lines changed

28 files changed

+52
-46
lines changed

.github/workflows/run-tests.yaml

+4-8
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ jobs:
2020
- uses: actions/checkout@v3
2121
- name: Run task 'build'
2222
shell: cmd
23-
run: |
24-
./build.cmd build
23+
run: ./build.cmd build
2524
- name: Run task 'in-tests-core'
2625
shell: cmd
27-
run: |
28-
./build.cmd in-tests-core -e
26+
run: ./build.cmd in-tests-core -e
2927
- name: Upload test results
3028
uses: actions/upload-artifact@v3
3129
if: always()
@@ -42,12 +40,10 @@ jobs:
4240
- uses: actions/checkout@v3
4341
- name: Run task 'build'
4442
shell: cmd
45-
run: |
46-
./build.cmd build
43+
run: ./build.cmd build
4744
- name: Run task 'in-tests-full'
4845
shell: cmd
49-
run: |
50-
./build.cmd in-tests-full -e
46+
run: ./build.cmd in-tests-full -e
5147
- name: Upload test results
5248
uses: actions/upload-artifact@v3
5349
if: always()

build/BenchmarkDotNet.Build/BenchmarkDotNet.Build.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
88
<ItemGroup>
9-
<PackageReference Include="Cake.Frosting" Version="3.0.0" />
9+
<PackageReference Include="Cake.Frosting" Version="3.2.0" />
1010
<PackageReference Include="Cake.FileHelpers" Version="6.1.3" />
1111
<PackageReference Include="Cake.Git" Version="3.0.0" />
1212
<PackageReference Include="Docfx.App" Version="2.71.1" />

build/BenchmarkDotNet.Build/BuildContext.cs

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ public BuildContext(ICakeContext context)
5959
BuildDirectory = RootDirectory.Combine("build");
6060
ArtifactsDirectory = RootDirectory.Combine("artifacts");
6161

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

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

build/BenchmarkDotNet.Build/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public class InTestsFullTask : FrostingTask<BuildContext>, IHelpProvider
9898
public class InTestsCoreTask : FrostingTask<BuildContext>, IHelpProvider
9999
{
100100
private const string Name = "in-tests-core";
101-
public override void Run(BuildContext context) => context.UnitTestRunner.RunInTests("net7.0");
101+
public override void Run(BuildContext context) => context.UnitTestRunner.RunInTests("net8.0");
102102
public HelpInfo GetHelp() => new();
103103
}
104104

build/BenchmarkDotNet.Build/Runners/BuildRunner.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public void Restore()
2424
context.DotNetRestore(context.SolutionFile.FullPath,
2525
new DotNetRestoreSettings
2626
{
27-
MSBuildSettings = context.MsBuildSettingsRestore
27+
MSBuildSettings = context.MsBuildSettingsRestore,
28+
Verbosity = DotNetVerbosity.Normal
2829
});
2930
}
3031

build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ private void RunTests(FilePath projectFile, string alias, string tfm)
6363
public void RunUnitTests()
6464
{
6565
var targetFrameworks = context.IsRunningOnWindows()
66-
? new[] { "net462", "net7.0" }
67-
: new[] { "net7.0" };
66+
? new[] { "net462", "net8.0" }
67+
: new[] { "net8.0" };
6868

6969
foreach (var targetFramework in targetFrameworks)
7070
RunUnitTests(targetFramework);

build/build.ps1

+2-3
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,10 @@ if (!(Test-Path $InstallPath)) {
5858
$ScriptPath = Join-Path $InstallPath 'dotnet-install.ps1'
5959
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, $ScriptPath);
6060
& $ScriptPath -JSonFile $GlobalJsonPath -InstallDir $InstallPath;
61-
62-
Remove-PathVariable "$InstallPath"
63-
$env:PATH = "$InstallPath;$env:PATH"
6461
}
6562

63+
Remove-PathVariable "$InstallPath"
64+
$env:PATH = "$InstallPath;$env:PATH"
6665
$env:DOTNET_ROOT=$InstallPath
6766

6867
###########################################################################

build/sdk/global.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "7.0.401",
3+
"version": "8.0.100",
44
"rollForward": "disable"
55
}
66
}

samples/BenchmarkDotNet.Samples.FSharp/BenchmarkDotNet.Samples.FSharp.fsproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66
<PropertyGroup>
77
<OutputType>Exe</OutputType>
8-
<TargetFrameworks>net462;net7.0</TargetFrameworks>
8+
<TargetFrameworks>net462;net8.0</TargetFrameworks>
99
</PropertyGroup>
1010
<ItemGroup>
1111
<Compile Include="Program.fs" />

samples/BenchmarkDotNet.Samples/BenchmarkDotNet.Samples.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Import Project="..\..\build\common.props" />
33
<PropertyGroup>
44
<AssemblyTitle>BenchmarkDotNet.Samples</AssemblyTitle>
5-
<TargetFrameworks>net7.0;net462</TargetFrameworks>
5+
<TargetFrameworks>net8.0;net462</TargetFrameworks>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
<AssemblyName>BenchmarkDotNet.Samples</AssemblyName>
88
<OutputType>Exe</OutputType>

tests/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Import Project="..\..\build\common.props" />
33
<PropertyGroup>
44
<AssemblyTitle>BenchmarkDotNet.IntegrationTests.ConfigPerAssembly</AssemblyTitle>
5-
<TargetFrameworks>net462;net7.0</TargetFrameworks>
5+
<TargetFrameworks>net462;net8.0</TargetFrameworks>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
<AssemblyName>BenchmarkDotNet.IntegrationTests.ConfigPerAssembly</AssemblyName>
88
<PackageId>BenchmarkDotNet.IntegrationTests.ConfigPerAssembly</PackageId>

tests/BenchmarkDotNet.IntegrationTests.DisabledOptimizations/BenchmarkDotNet.IntegrationTests.DisabledOptimizations.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Import Project="..\..\build\common.props" />
33
<PropertyGroup>
44
<AssemblyTitle>BenchmarkDotNet.IntegrationTests.DisabledOptimizations</AssemblyTitle>
5-
<TargetFrameworks>net462;net7.0</TargetFrameworks>
5+
<TargetFrameworks>net462;net8.0</TargetFrameworks>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
<AssemblyName>BenchmarkDotNet.IntegrationTests.DisabledOptimizations</AssemblyName>
88
<PackageId>BenchmarkDotNet.IntegrationTests.DisabledOptimizations</PackageId>

tests/BenchmarkDotNet.IntegrationTests.EnabledOptimizations/BenchmarkDotNet.IntegrationTests.EnabledOptimizations.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Import Project="..\..\build\common.props" />
33
<PropertyGroup>
44
<AssemblyTitle>BenchmarkDotNet.IntegrationTests.EnabledOptimizations</AssemblyTitle>
5-
<TargetFrameworks>net462;net7.0</TargetFrameworks>
5+
<TargetFrameworks>net462;net8.0</TargetFrameworks>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
<AssemblyName>BenchmarkDotNet.IntegrationTests.EnabledOptimizations</AssemblyName>
88
<PackageId>BenchmarkDotNet.IntegrationTests.EnabledOptimizations</PackageId>

tests/BenchmarkDotNet.IntegrationTests.FSharp/BenchmarkDotNet.IntegrationTests.FSharp.fsproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66
<Import Project="..\..\build\common.props" />
77
<PropertyGroup>
8-
<TargetFrameworks>net462;net7.0</TargetFrameworks>
8+
<TargetFrameworks>net462;net8.0</TargetFrameworks>
99
<PublicSign>false</PublicSign>
1010
</PropertyGroup>
1111
<ItemGroup>

tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<AssemblyTitle>BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks</AssemblyTitle>
55
<!-- We test the oldest frameworks supported by BDN (net461 and netcoreapp2.0), as well as newer versions of those frameworks. -->
66
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
7-
<TargetFrameworks>net461;net48;netcoreapp2.0;net7.0</TargetFrameworks>
7+
<TargetFrameworks>net461;net48;netcoreapp2.0;net8.0</TargetFrameworks>
88
<NoWarn>$(NoWarn);NU1903</NoWarn> <!-- NU1903: Package 'Microsoft.NETCore.App' 2.0.0 has a known high severity vulnerability -->
99
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1010
<AssemblyName>BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks</AssemblyName>

tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Import Project="..\..\build\common.props" />
33
<PropertyGroup>
44
<AssemblyTitle>BenchmarkDotNet.IntegrationTests.ManualRunning</AssemblyTitle>
5-
<TargetFrameworks>net462;net7.0</TargetFrameworks>
5+
<TargetFrameworks>net462;net8.0</TargetFrameworks>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
<AssemblyName>BenchmarkDotNet.IntegrationTests.ManualRunning</AssemblyName>
88
<PackageId>BenchmarkDotNet.IntegrationTests.ManualRunning</PackageId>

tests/BenchmarkDotNet.IntegrationTests.Static/BenchmarkDotNet.IntegrationTests.Static.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Import Project="..\..\build\common.props" />
33
<PropertyGroup>
44
<AssemblyTitle>BenchmarkDotNet.IntegrationTests.Static</AssemblyTitle>
5-
<TargetFrameworks>net462;net7.0</TargetFrameworks>
5+
<TargetFrameworks>net462;net8.0</TargetFrameworks>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
<AssemblyName>BenchmarkDotNet.IntegrationTests.Static</AssemblyName>
88
<PackageId>BenchmarkDotNet.IntegrationTests.Static</PackageId>

tests/BenchmarkDotNet.IntegrationTests.VisualBasic/BenchmarkDotNet.IntegrationTests.VisualBasic.vbproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66
<Import Project="..\..\build\common.props" />
77
<PropertyGroup>
8-
<TargetFrameworks>net462;net7.0</TargetFrameworks>
8+
<TargetFrameworks>net462;net8.0</TargetFrameworks>
99
</PropertyGroup>
1010
<ItemGroup>
1111
<ProjectReference Include="..\..\src\BenchmarkDotNet\BenchmarkDotNet.csproj" />

tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<Import Project="..\..\build\common.props" />
33
<PropertyGroup>
44
<AssemblyTitle>BenchmarkDotNet.IntegrationTests</AssemblyTitle>
5-
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">net462;net7.0</TargetFrameworks>
6-
<TargetFramework Condition="'$(OS)' != 'Windows_NT'">net7.0</TargetFramework>
5+
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">net462;net8.0</TargetFrameworks>
6+
<TargetFramework Condition="'$(OS)' != 'Windows_NT'">net8.0</TargetFramework>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88
<AssemblyName>BenchmarkDotNet.IntegrationTests</AssemblyName>
99
<PackageId>BenchmarkDotNet.IntegrationTests</PackageId>

tests/BenchmarkDotNet.IntegrationTests/BuildTimeoutTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ public void WhenBuildTakesMoreTimeThanTheTimeoutTheBuildIsCancelled()
2929
var config = ManualConfig.CreateEmpty()
3030
.WithBuildTimeout(timeout)
3131
.AddJob(Job.Dry
32-
.WithRuntime(NativeAotRuntime.Net70)
32+
.WithRuntime(NativeAotRuntime.Net80)
3333
.WithToolchain(NativeAotToolchain.CreateBuilder()
34-
.UseNuGet("7.0.0", "https://api.nuget.org/v3/index.json")
35-
.TargetFrameworkMoniker("net7.0")
34+
.UseNuGet("8.0.0", "https://api.nuget.org/v3/index.json")
35+
.TargetFrameworkMoniker("net8.0")
3636
.ToToolchain()));
3737

3838
var summary = CanExecute<NativeAotBenchmark>(config, fullValidation: false);

tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public static IEnumerable<object[]> GetAllJits()
3434
{
3535
if (RuntimeInformation.GetCurrentPlatform() is Platform.X86 or Platform.X64)
3636
{
37-
yield return new object[] { Jit.RyuJit, Platform.X64, CoreRuntime.Core70 }; // .NET Core x64
37+
yield return new object[] { Jit.RyuJit, Platform.X64, CoreRuntime.Core80 }; // .NET Core x64
3838
}
3939
else if (RuntimeInformation.GetCurrentPlatform() is Platform.Arm64 && RuntimeInformation.IsLinux())
4040
{
41-
yield return new object[] { Jit.RyuJit, Platform.Arm64, CoreRuntime.Core70 }; // .NET Core arm64
41+
yield return new object[] { Jit.RyuJit, Platform.Arm64, CoreRuntime.Core80 }; // .NET Core arm64
4242
}
4343
}
4444
if (RuntimeInformation.IsMacOS())

tests/BenchmarkDotNet.IntegrationTests/JitRuntimeValidationTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static IEnumerable<object[]> CheckCore_Arguments()
5151
[MemberData(nameof(CheckCore_Arguments))]
5252
public void CheckCore(Jit jit, Platform platform, string errorMessage)
5353
{
54-
Verify(CoreRuntime.Core70, jit, platform, errorMessage);
54+
Verify(CoreRuntime.Core80, jit, platform, errorMessage);
5555
}
5656

5757
private void Verify(Runtime runtime, Jit jit, Platform platform, string errorMessage)

tests/BenchmarkDotNet.IntegrationTests/LargeAddressAwareTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void BenchmarkCanAllocateMoreThan2Gb()
4747
.Any());
4848

4949
Assert.Contains(".NET Framework", summary.AllRuntimes);
50-
Assert.Contains(".NET 7.0", summary.AllRuntimes);
50+
Assert.Contains(".NET 8.0", summary.AllRuntimes);
5151
}
5252
}
5353

tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ public void MemoryDiagnoserSupportsNativeAOT()
8181
.ToToolchain());
8282
}
8383

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

9090
public class AllocatingGlobalSetupAndCleanup

tests/BenchmarkDotNet.IntegrationTests/MonoTests.cs

+11-4
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,23 @@
44
using BenchmarkDotNet.Environments;
55
using BenchmarkDotNet.Jobs;
66
using BenchmarkDotNet.Portability;
7+
using BenchmarkDotNet.Tests.Loggers;
78
using BenchmarkDotNet.Tests.XUnit;
9+
using Xunit.Abstractions;
810

911
namespace BenchmarkDotNet.IntegrationTests
1012
{
1113
public class MonoTests : BenchmarkTestExecutor
1214
{
15+
public MonoTests(ITestOutputHelper output) : base(output) { }
16+
1317
[FactEnvSpecific("UseMonoRuntime option is available in .NET Core only starting from .NET 6", EnvRequirement.DotNetCoreOnly)]
14-
public void Mono70IsSupported()
18+
public void Mono80IsSupported()
1519
{
16-
var config = ManualConfig.CreateEmpty().AddJob(Job.Dry.WithRuntime(MonoRuntime.Mono70));
20+
var logger = new OutputLogger(Output);
21+
var config = ManualConfig.CreateEmpty()
22+
.AddLogger(logger)
23+
.AddJob(Job.Dry.WithRuntime(MonoRuntime.Mono80));
1724
CanExecute<MonoBenchmark>(config);
1825
}
1926

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

30-
if (RuntimeInformation.GetCurrentRuntime() != MonoRuntime.Mono70)
37+
if (RuntimeInformation.GetCurrentRuntime() != MonoRuntime.Mono80)
3138
{
3239
throw new Exception("Incorrect runtime detection");
3340
}
3441
}
3542
}
3643
}
37-
}
44+
}

tests/BenchmarkDotNet.IntegrationTests/MultipleRuntimesTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void SingleBenchmarkCanBeExecutedForMultipleRuntimes()
5151
.Any());
5252

5353
Assert.Contains(".NET Framework", summary.AllRuntimes);
54-
Assert.Contains(".NET 7.0", summary.AllRuntimes);
54+
Assert.Contains(".NET 8.0", summary.AllRuntimes);
5555
}
5656
}
5757

tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Import Project="..\..\build\common.props" />
33
<PropertyGroup>
44
<AssemblyTitle>BenchmarkDotNet.Tests</AssemblyTitle>
5-
<TargetFrameworks>net7.0;net462</TargetFrameworks>
5+
<TargetFrameworks>net8.0;net462</TargetFrameworks>
66
<AssemblyName>BenchmarkDotNet.Tests</AssemblyName>
77
<PackageId>BenchmarkDotNet.Tests</PackageId>
88
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>

tests/BenchmarkDotNet.Tests/ConfigParserTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public void SpecifyingCoreRunWithFullFrameworkTargetsMostRecentTfm()
168168
[FactEnvSpecific("It's impossible to determine TFM for CoreRunToolchain if host process is not .NET (Core) process", EnvRequirement.DotNetCoreOnly)]
169169
public void SpecifyingCoreRunAndRuntimeCreatesTwoJobs()
170170
{
171-
const string runtime = "net7.0";
171+
const string runtime = "net8.0";
172172
var fakeDotnetCliPath = typeof(object).Assembly.Location;
173173
var fakeCoreRunPath = typeof(ConfigParserTests).Assembly.Location;
174174
var fakeRestorePackages = Path.GetTempPath();

0 commit comments

Comments
 (0)