Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow RunSettingsArguments to be set #2771

Merged
merged 5 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Release Notes

## 6.1.0 - 2024-07-27
* BUGFIX: Allow RunSettingsArguments to be set, thanks @TheAngryByrd - https://github.com/fsprojects/FAKE/pull/2771
TheAngryByrd marked this conversation as resolved.
Show resolved Hide resolved
* BUGFIX: MSBuild.build adds a bad string at the end of properties, thanks @0x53A - https://github.com/fsprojects/FAKE/issues/2738
* BUGFIX: Allow setting Msbuild max cpu on Linux, thanks @TheAngryByrd - https://github.com/fsprojects/FAKE/pull/2772
* ENHANCEMENT: Added shorthash to git functions, thanks @voronoipotato - https://github.com/fsprojects/FAKE/pull/2752
Expand Down
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."

]
Loading