From 9ca3eb57d519e30dcba097567e61aaf83326c064 Mon Sep 17 00:00:00 2001 From: Ruben Bartelink Date: Sat, 30 May 2026 15:29:14 +0100 Subject: [PATCH] Add Project/Solution fields to DotNet.TestOptions for SDK 10 support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SDK 10 no longer accepts positional project/solution args for 'dotnet test'. Instead, '--project' or '--solution' flags must be used. This adds: - Project: string option → --project flag - Solution: string option → --solution flag - Filters empty positional 'project' arg from the command (avoids crash when using Project/Solution fields with empty string as positional arg) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/app/Fake.DotNet.Cli/DotNet.fs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/app/Fake.DotNet.Cli/DotNet.fs b/src/app/Fake.DotNet.Cli/DotNet.fs index 98f0ab4e668..aeebed979f2 100644 --- a/src/app/Fake.DotNet.Cli/DotNet.fs +++ b/src/app/Fake.DotNet.Cli/DotNet.fs @@ -1766,6 +1766,16 @@ module DotNet = /// order of tests execution before the crash. (--blame) Blame: bool + /// Specifies the project to test via the --project flag (SDK 10+). + /// When set, overrides the positional project argument passed to . + /// Use this instead of the positional argument when targeting SDK 10+ with Microsoft.Testing.Platform. + /// (--project) + Project: string option + + /// Specifies the solution to test via the --solution flag (SDK 10+). + /// (--solution) + Solution: string option + /// Other msbuild specific parameters MSBuildParams: MSBuild.CliArguments } @@ -1789,6 +1799,8 @@ module DotNet = NoRestore = false RunSettingsArguments = None Blame = false + Project = None + Solution = None MSBuildParams = MSBuild.CliArguments.Create() } /// Gets the current environment @@ -1820,7 +1832,9 @@ module DotNet = param.ResultsDirectory |> Option.toList |> argList2 "results-directory" param.Collect |> Option.toList |> argList2 "collect" param.NoRestore |> argOption "no-restore" - param.Blame |> argOption "blame" ] + param.Blame |> argOption "blame" + param.Project |> Option.toList |> argList2 "project" + param.Solution |> Option.toList |> argList2 "solution" ] |> List.concat |> List.filter (not << String.IsNullOrEmpty) @@ -1834,7 +1848,8 @@ module DotNet = let test setParams project = use __ = Trace.traceTask "DotNet:test" project let param = TestOptions.Create() |> setParams - let args = project :: buildTestArgs param + let positionalArg = if String.IsNullOrEmpty project then [] else [ project ] + let args = positionalArg @ buildTestArgs param execWithBinLog project param.Common "test" args param.MSBuildParams param.RunSettingsArguments __.MarkSuccess()