{"record":{"id":"852e68216e492174","repo":"dotnet/BenchmarkDotNet","slug":"you-must-specify-the-target-framework-moniker-in-e","errorCode":null,"errorMessage":"You must specify the target framework moniker in explicit way using builder.TargetFrameworkMoniker(tfm) method","messagePattern":"You must specify the target framework moniker in explicit way using builder\\.TargetFrameworkMoniker\\(tfm\\) method","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/BenchmarkDotNet/Toolchains/DotNetCli/CustomDotNetCliToolchainBuilder.cs","lineNumber":65,"sourceCode":"            return this;\n        }\n\n        /// <param name=\"targetFrameworkMoniker\">TFM, example: net10.0</param>\n        [PublicAPI]\n        [SuppressMessage(\"ReSharper\", \"ParameterHidesMember\")]\n        public CustomDotNetCliToolchainBuilder TargetFrameworkMoniker(string targetFrameworkMoniker)\n        {\n            this.targetFrameworkMoniker = targetFrameworkMoniker ?? throw new ArgumentNullException(nameof(targetFrameworkMoniker));\n\n            return this;\n        }\n\n        protected string GetTargetFrameworkMoniker()\n        {\n            if (targetFrameworkMoniker.IsNotBlank())\n                return targetFrameworkMoniker;\n            if (!Portability.RuntimeInformation.IsNetCore)\n                throw new NotSupportedException(\"You must specify the target framework moniker in explicit way using builder.TargetFrameworkMoniker(tfm) method\");\n\n            return CoreRuntime.GetCurrentVersion().MsBuildMoniker;\n        }\n\n        /// <param name=\"newCustomDotNetCliPath\">if not provided, the one from PATH will be used</param>\n        [PublicAPI]\n        public CustomDotNetCliToolchainBuilder DotNetCli(string newCustomDotNetCliPath)\n        {\n            if (newCustomDotNetCliPath.IsNotBlank() && !File.Exists(newCustomDotNetCliPath))\n                throw new FileNotFoundException(\"Given file does not exist\", newCustomDotNetCliPath);\n\n            customDotNetCliPath = newCustomDotNetCliPath;\n\n            return this;\n        }\n\n        /// <param name=\"newRuntimeIdentifier\">if not provided, portable OS-arch will be used (example: \"win-x64\", \"linux-x86\")</param>\n        [PublicAPI]","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/dotnet/BenchmarkDotNet/blob/b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3/src/BenchmarkDotNet/Toolchains/DotNetCli/CustomDotNetCliToolchainBuilder.cs#L47-L83","documentation":"When the host process is not running on .NET Core, BenchmarkDotNet cannot infer the target framework moniker, so the custom dotnet CLI toolchain requires it to be specified explicitly.","triggerScenarios":"Thrown at src/BenchmarkDotNet/Toolchains/DotNetCli/CustomDotNetCliToolchainBuilder.cs:65 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call builder.TargetFrameworkMoniker(tfm) explicitly when building a custom toolchain on a non-.NET Core runtime.","Run the benchmark host process on .NET (Core) so the current TFM can be detected automatically."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3","analyzedAt":"2026-08-13T19:12:24.196Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}