@@ -32,7 +32,7 @@ protected override async Task RunJobCoreAsync()
3232 {
3333 await clonePerformanceTask ;
3434
35- PendingTasks . Enqueue ( RuntimeHelpers . InstallDotnetSdkAsync ( this , "performance/global.json" , DotnetInstallDir ) ) ;
35+ PendingTasks . Enqueue ( Task . Run ( InstallDotnetSdksAsync ) ) ;
3636
3737 coreRuns = await DownloadCoreRootsAsync ( entries ) ;
3838 }
@@ -65,22 +65,20 @@ protected override async Task RunJobCoreAsync()
6565 await JitDiffJob . BuildAndCopyRuntimeBranchBitsAsync ( this , "pr" , uploadArtifacts : false , buildChecked : false , canSkipRebuild : false ) ;
6666 }
6767
68- await RuntimeHelpers . InstallRuntimeDotnetSdkAsync ( this , DotnetInstallDir ) ;
69-
70- await RuntimeHelpers . InstallDotnetSdkAsync ( this , "performance/global.json" , DotnetInstallDir ) ;
68+ await InstallDotnetSdksAsync ( ) ;
7169
7270 coreRuns = [ "artifacts-main/corerun" , "artifacts-pr/corerun" ] ;
7371 }
7472
7573 await WaitForPendingTasksAsync ( ) ;
7674
77- try
75+ await RunBenchmarksAsync ( coreRuns ) ;
76+
77+ async Task InstallDotnetSdksAsync ( )
7878 {
79- File . Delete ( "../NuGet.config" ) ;
79+ await DotnetHelpers . InstallDotnetSdkAsync ( this , "performance/global.json" , DotnetInstallDir ) ;
80+ await DotnetHelpers . InstallDotnetDailySdkAsync ( this , GetPerformanceDotnetVersion ( ) , DotnetInstallDir ) ;
8081 }
81- catch { }
82-
83- await RunBenchmarksAsync ( coreRuns ) ;
8482 }
8583
8684 private async Task CloneDotnetPerformanceAndSetupToolsAsync ( )
@@ -193,6 +191,23 @@ private async Task CloneDotnetPerformanceAndSetupToolsAsync()
193191 }
194192 }
195193
194+ private int GetPerformanceDotnetVersion ( )
195+ {
196+ string source = File . ReadAllText ( "performance/src/benchmarks/micro/MicroBenchmarks.csproj" ) ;
197+ // <SupportedTargetFrameworks>net6.0;net7.0;net8.0;net9.0;net10.0;net11.0</SupportedTargetFrameworks>
198+
199+ Match match = DotnetVersionFromCsprojRegex ( ) . Match ( source ) ;
200+
201+ if ( ! match . Success )
202+ {
203+ throw new Exception ( "Failed to determine the dotnet version from MicroBenchmarks.csproj" ) ;
204+ }
205+
206+ // ["net6.0", "net7.0", ...]
207+ string [ ] frameworks = match . Groups [ 1 ] . Value . Split ( ';' , StringSplitOptions . RemoveEmptyEntries ) ;
208+ return frameworks . Max ( f => int . Parse ( f . AsSpan ( 3 , f . IndexOf ( '.' ) - 3 ) ) ) ;
209+ }
210+
196211 private async Task < string [ ] > DownloadCoreRootsAsync ( CoreRootAPI . CoreRootEntry [ ] entries )
197212 {
198213 for ( int i = 0 ; i < entries . Length ; i ++ )
@@ -229,7 +244,7 @@ private async Task RunBenchmarksAsync(string[] coreRunPaths)
229244 filter = $ "*{ filter } *";
230245 }
231246
232- int dotnetVersion = RuntimeHelpers . GetDotnetVersion ( "performance" ) ;
247+ int dotnetVersion = GetPerformanceDotnetVersion ( ) ;
233248
234249 string coreRuns = string . Join ( ' ' , coreRunPaths . Select ( p => $ "\" { Path . GetFullPath ( p ) } \" ") ) ;
235250
@@ -386,4 +401,7 @@ await RunProcessAsync(dotnetPath,
386401
387402 [ GeneratedRegex ( @"BenchmarkDotNet\.(\d.*?)\.nupkg" ) ]
388403 private static partial Regex BenchmarkDotNetPackageVersionRegex ( ) ;
404+
405+ [ GeneratedRegex ( @"Frameworks>((?:net\d+\.\d+);?)+<\/" ) ]
406+ private static partial Regex DotnetVersionFromCsprojRegex ( ) ;
389407}
0 commit comments