Skip to content

Commit

Permalink
Allow RunSettingsArguments to be set
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAngryByrd committed Jan 29, 2024
1 parent 82e38df commit 35ace1b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
32 changes: 23 additions & 9 deletions src/app/Fake.DotNet.Cli/DotNet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1173,21 +1173,33 @@ module DotNet =

MSBuild.addBinaryLogger (common.DotNetCliPath + " msbuild") callMsBuildExe args disableFakeBinLog

let internal execWithBinLog project common command args msBuildArgs =
let internal buildAfterArgs args afterArgs =
[ yield! args
match afterArgs with
| Some a ->
yield "--"
yield a
| None -> () ]

let internal execWithBinLog project common command args msBuildArgs afterArgs =
let msbuildArgList = MSBuild.fromCliArguments msBuildArgs

let binLogPath, args =
addBinaryLogger msBuildArgs.DisableInternalBinLog (args @ msbuildArgList) common

let args = buildAfterArgs args afterArgs

let result = execArgsList (fun _ -> common) command args
MSBuild.handleAfterRun (sprintf "dotnet %s" command) binLogPath result.ExitCode project

let internal tryExecWithBinLog project common command args msBuildArgs =
let internal tryExecWithBinLog project common command args msBuildArgs afterArgs =
let msbuildArgList = MSBuild.fromCliArguments msBuildArgs

let binLogPath, args =
addBinaryLogger msBuildArgs.DisableInternalBinLog (args @ msbuildArgList) common

let args = buildAfterArgs args afterArgs

let result = execArgsList (fun _ -> common) command args

try
Expand Down Expand Up @@ -1230,7 +1242,7 @@ module DotNet =

let param = MSBuildOptions.Create() |> setParams
let args = [ project ]
execWithBinLog project param.Common "msbuild" args param.MSBuildParams
execWithBinLog project param.Common "msbuild" args param.MSBuildParams None
__.MarkSuccess()

// TODO: Make this API public? change return code?
Expand All @@ -1239,7 +1251,9 @@ module DotNet =

let param = MSBuildOptions.Create() |> setParams
let args = [ project ]
let r = tryExecWithBinLog project param.Common "msbuild" args param.MSBuildParams

let r =
tryExecWithBinLog project param.Common "msbuild" args param.MSBuildParams None
//__.MarkSuccess()
r

Expand Down Expand Up @@ -1326,7 +1340,7 @@ module DotNet =
use __ = Trace.traceTask "DotNet:restore" project
let param = RestoreOptions.Create() |> setParams
let args = project :: buildRestoreArgs param
execWithBinLog project param.Common "restore" args param.MSBuildParams
execWithBinLog project param.Common "restore" args param.MSBuildParams None
__.MarkSuccess()

/// build configuration
Expand Down Expand Up @@ -1463,7 +1477,7 @@ module DotNet =
use __ = Trace.traceTask "DotNet:pack" project
let param = PackOptions.Create() |> setParams
let args = project :: buildPackArgs param
execWithBinLog project param.Common "pack" args param.MSBuildParams
execWithBinLog project param.Common "pack" args param.MSBuildParams None
__.MarkSuccess()

/// <summary>
Expand Down Expand Up @@ -1580,7 +1594,7 @@ module DotNet =
use __ = Trace.traceTask "DotNet:publish" project
let param = PublishOptions.Create() |> setParams
let args = project :: buildPublishArgs param
execWithBinLog project param.Common "publish" args param.MSBuildParams
execWithBinLog project param.Common "publish" args param.MSBuildParams None
__.MarkSuccess()

/// <summary>
Expand Down Expand Up @@ -1670,7 +1684,7 @@ module DotNet =
use __ = Trace.traceTask "DotNet:build" project
let param = BuildOptions.Create() |> setParams
let args = project :: buildBuildArgs param
execWithBinLog project param.Common "build" args param.MSBuildParams
execWithBinLog project param.Common "build" args param.MSBuildParams None
__.MarkSuccess()

/// <summary>
Expand Down Expand Up @@ -1821,7 +1835,7 @@ module DotNet =
use __ = Trace.traceTask "DotNet:test" project
let param = TestOptions.Create() |> setParams
let args = project :: buildTestArgs param
execWithBinLog project param.Common "test" args param.MSBuildParams
execWithBinLog project param.Common "test" args param.MSBuildParams param.RunSettingsArguments
__.MarkSuccess()

let internal buildNugetPushArgs (param: NuGet.NuGetPushParams) =
Expand Down
20 changes: 19 additions & 1 deletion src/test/Fake.Core.UnitTests/Fake.DotNet.Cli.fs
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,22 @@ let tests =

let expected = "--uninstall my-awesome-template"

Expect.equal cli expected "New --uninstall args generated correctly." ]
Expect.equal cli expected "New --uninstall args generated correctly."

testCase "Test buildAfterArgs with no after args"
<| fun _ ->
let expected = "hello"
let cli = DotNet.buildAfterArgs [ "hello" ] None |> Args.toWindowsCommandLine

Expect.equal cli expected "Empty after args."

testCase "Test buildAfterArgs with after args"
<| fun _ ->
let expected = "hello -- lol=foo"

let cli =
DotNet.buildAfterArgs [ "hello" ] (Some "lol=foo") |> Args.toWindowsCommandLine

Expect.equal cli expected "Empty after args."

]

0 comments on commit 35ace1b

Please sign in to comment.