dotnet/BenchmarkDotNet · error · FileNotFoundException

Given file does not exist

Error message

Given file does not exist

What it means

CustomDotNetCliToolchainBuilder.DotNetCli checks that a provided custom dotnet CLI path exists on disk and throws FileNotFoundException when it does not.

Source

Thrown at src/BenchmarkDotNet/Toolchains/DotNetCli/CustomDotNetCliToolchainBuilder.cs:75

            return this;
        }

        protected string GetTargetFrameworkMoniker()
        {
            if (targetFrameworkMoniker.IsNotBlank())
                return targetFrameworkMoniker;
            if (!Portability.RuntimeInformation.IsNetCore)
                throw new NotSupportedException("You must specify the target framework moniker in explicit way using builder.TargetFrameworkMoniker(tfm) method");

            return CoreRuntime.GetCurrentVersion().MsBuildMoniker;
        }

        /// <param name="newCustomDotNetCliPath">if not provided, the one from PATH will be used</param>
        [PublicAPI]
        public CustomDotNetCliToolchainBuilder DotNetCli(string newCustomDotNetCliPath)
        {
            if (newCustomDotNetCliPath.IsNotBlank() && !File.Exists(newCustomDotNetCliPath))
                throw new FileNotFoundException("Given file does not exist", newCustomDotNetCliPath);

            customDotNetCliPath = newCustomDotNetCliPath;

            return this;
        }

        /// <param name="newRuntimeIdentifier">if not provided, portable OS-arch will be used (example: "win-x64", "linux-x86")</param>
        [PublicAPI]
        public CustomDotNetCliToolchainBuilder RuntimeIdentifier(string newRuntimeIdentifier)
        {
            runtimeIdentifier = newRuntimeIdentifier;

            return this;
        }

        /// <param name="newRuntimeFrameworkVersion">optional, when set it's copied to the generated .csproj file</param>
        [PublicAPI]
        public CustomDotNetCliToolchainBuilder RuntimeFrameworkVersion(string newRuntimeFrameworkVersion)

View on GitHub (pinned to b515068b61)

Solutions

  1. Verify the path passed to DotNetCli() points to an existing dotnet executable (dotnet or dotnet.exe).
  2. Omit the custom path so the dotnet CLI from PATH is used instead.
  3. Check for typos, and use an absolute path.

When it happens

Trigger: Thrown at src/BenchmarkDotNet/Toolchains/DotNetCli/CustomDotNetCliToolchainBuilder.cs:75 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of dotnet/BenchmarkDotNet@b515068b61 (2026-08-13). Data as JSON: /api/errors/adb79d3a6748b2a2. Report an issue: GitHub.