Skip to content

Commit

Permalink
Allow RunSettingsArguments to be set (#2771)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAngryByrd committed Aug 31, 2024
1 parent 3e5e3f0 commit bb0dce7
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 12 deletions.
5 changes: 3 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Release Notes

## 6.1.1 - 2024-08-19
* BUGFIX: Assembly resolver to pick a found SDK instead of first SDK - https://github.com/fsprojects/FAKE/pull/2797/files
## 6.1.1 - 2024-08-30
* BUGFIX: Assembly resolver to pick a found SDK instead of first SDK, thanks @Thorium - https://github.com/fsprojects/FAKE/pull/2797/files
* BUGFIX: Fix issue parsing global.json when using prerelease .NET SDKs, thanks @numpsy - https://github.com/fsprojects/FAKE/issues/2803
* BUGFIX: Allow RunSettingsArguments to be set, thanks @TheAngryByrd - https://github.com/fsprojects/FAKE/pull/2771

## 6.1.0 - 2024-07-27
* BUGFIX: MSBuild.build adds a bad string at the end of properties, thanks @0x53A - https://github.com/fsprojects/FAKE/issues/2738
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 @@ -1170,21 +1170,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 @@ -1227,7 +1239,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 @@ -1236,7 +1248,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 @@ -1323,7 +1337,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 @@ -1460,7 +1474,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 @@ -1577,7 +1591,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 @@ -1667,7 +1681,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 @@ -1818,7 +1832,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 bb0dce7

Please sign in to comment.