diff --git a/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs b/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs index 493a55e3d6..0acb890527 100644 --- a/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs +++ b/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs @@ -392,7 +392,7 @@ private static Job CreateJobForGivenRuntime(Job baseJob, string runtimeId, Comma case RuntimeMoniker.NativeAot60: return CreateAotJob(baseJob, options, runtimeMoniker, "6.0.0-*", "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json"); case RuntimeMoniker.NativeAot70: - return CreateAotJob(baseJob, options, runtimeMoniker, "7.0.0-*", "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json"); + return CreateAotJob(baseJob, options, runtimeMoniker, "", "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json"); case RuntimeMoniker.Wasm: return MakeWasmJob(baseJob, options, RuntimeInformation.IsNetCore ? CoreRuntime.GetCurrentVersion().MsBuildMoniker : "net5.0", runtimeMoniker); case RuntimeMoniker.WasmNet50: diff --git a/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs b/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs index 8b87622630..238728bea4 100644 --- a/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs +++ b/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs @@ -132,6 +132,7 @@ private string GenerateProjectForNuGetBuild(BuildPartition buildPartition, Artif false true false + true {ilcOptimizationPreference} {GetTrimmingSettings()} {ilcGenerateCompleteTypeMetadata} @@ -146,7 +147,7 @@ private string GenerateProjectForNuGetBuild(BuildPartition buildPartition, Artif - + {GetILCompilerPackageReference()} @@ -154,6 +155,9 @@ private string GenerateProjectForNuGetBuild(BuildPartition buildPartition, Artif "; + private string GetILCompilerPackageReference() + => string.IsNullOrEmpty(ilCompilerVersion) ? "" : $@""; + private string GetTrimmingSettings() => rootAllApplicationAssemblies ? "" // use the defaults diff --git a/src/BenchmarkDotNet/Toolchains/NativeAot/NativeAotToolchain.cs b/src/BenchmarkDotNet/Toolchains/NativeAot/NativeAotToolchain.cs index e795d95a63..a2eb6183f0 100644 --- a/src/BenchmarkDotNet/Toolchains/NativeAot/NativeAotToolchain.cs +++ b/src/BenchmarkDotNet/Toolchains/NativeAot/NativeAotToolchain.cs @@ -14,10 +14,10 @@ public class NativeAotToolchain : Toolchain .ToToolchain(); /// - /// compiled as net7.0, targets latest (7.0.0-*) NativeAOT build from the .NET 7 feed: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json + /// compiled as net7.0, targets latest NativeAOT build from the .NET 7 feed: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json /// public static readonly IToolchain Net70 = CreateBuilder() - .UseNuGet("7.0.0-*", "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json") + .UseNuGet("", "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json") .TargetFrameworkMoniker("net7.0") .ToToolchain(); diff --git a/src/BenchmarkDotNet/Toolchains/NativeAot/NativeAotToolchainBuilder.cs b/src/BenchmarkDotNet/Toolchains/NativeAot/NativeAotToolchainBuilder.cs index 07c4e7d5fc..f1dc1e220e 100644 --- a/src/BenchmarkDotNet/Toolchains/NativeAot/NativeAotToolchainBuilder.cs +++ b/src/BenchmarkDotNet/Toolchains/NativeAot/NativeAotToolchainBuilder.cs @@ -25,15 +25,17 @@ public class NativeAotToolchainBuilder : CustomDotNetCliToolchainBuilder /// creates a NativeAOT toolchain targeting NuGet build of Microsoft.DotNet.ILCompiler /// Based on https://github.com/dotnet/runtimelab/blob/d0a37893a67c125f9b0cd8671846ff7d867df241/samples/HelloWorld/README.md#add-corert-to-your-project /// - /// the version of Microsoft.DotNet.ILCompiler which should be used. The default is: "7.0.0-*" + /// the version of Microsoft.DotNet.ILCompiler which should be used. The default is empty which maps to latest version. /// url to NuGet feed, The default is: "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json" [PublicAPI] - public NativeAotToolchainBuilder UseNuGet(string microsoftDotNetILCompilerVersion = "7.0.0-*", string nuGetFeedUrl = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json") + public NativeAotToolchainBuilder UseNuGet(string microsoftDotNetILCompilerVersion = "", string nuGetFeedUrl = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json") { - ilCompilerVersion = microsoftDotNetILCompilerVersion ?? throw new ArgumentNullException(nameof(microsoftDotNetILCompilerVersion)); + ilCompilerVersion = microsoftDotNetILCompilerVersion; Feeds[Generator.NativeAotNuGetFeed] = nuGetFeedUrl ?? throw new ArgumentNullException(nameof(nuGetFeedUrl)); + DisplayName(string.IsNullOrEmpty(ilCompilerVersion) ? "Latest ILCompiler" : $"ILCompiler {ilCompilerVersion}"); + isIlCompilerConfigured = true; return this; @@ -54,6 +56,7 @@ public NativeAotToolchainBuilder UseLocalBuild(DirectoryInfo ilcPackages) ilCompilerVersion = "7.0.0-dev"; Feeds["dotnet7"] = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json"; useTempFolderForRestore = true; + DisplayName("local ILCompiler build"); isIlCompilerConfigured = true; @@ -148,7 +151,7 @@ public override IToolchain ToToolchain() throw new InvalidOperationException("You need to use UseNuGet or UseLocalBuild methods to tell us which ILCompiler to use."); return new NativeAotToolchain( - displayName: displayName ?? (ilCompilerVersion != null ? $"ILCompiler {ilCompilerVersion}" : "local ILCompiler build"), + displayName: displayName, ilCompilerVersion: ilCompilerVersion, runtimeFrameworkVersion: runtimeFrameworkVersion, targetFrameworkMoniker: GetTargetFrameworkMoniker(),