Skip to content

Commit

Permalink
Add Context.setExecutionContextFromCommandLineArgs
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Cameron Taggart <[email protected]>
  • Loading branch information
Numpsy and cataggar authored Jul 27, 2024
1 parent ea7b5bd commit d3f2de5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* ENHANCEMENT: Added shorthash to git functions, thanks @voronoipotato - https://github.com/fsprojects/FAKE/pull/2752
* ENHANCEMENT: Support for `/tl:[auto:on:off]` msbuild flag, thanks @smoothdeveloper - https://github.com/fsprojects/FAKE/pull/2768
* ENHANCEMENT: Fixes for usage in .NET 8.0 enviroment projects.
* ENHANCEMENT: Add Context.setExecutionContextFromCommandLineArgs, thanks @cataggar - https://github.com/fsprojects/FAKE/pull/2750

## 6.0.0 - 2023-02-20
* ENHANCEMENT: Site UI fixes and documentation link fixes.
Expand Down
11 changes: 11 additions & 0 deletions src/app/Fake.Core.Context/Context.fs
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,14 @@ module Context =
invalidOp
"no Fake Execution context was found. You can initialize one via Fake.Core.Context.setExecutionContext"
| RuntimeContext.Fake e -> e

/// <summary>
/// Creates and sets the FAKE execution context from command line arguments.
/// </summary>
let setExecutionContextFromCommandLineArgs scriptFile : unit =
System.Environment.GetCommandLineArgs()
|> Array.skip 2 // skip fsi & scriptFile
|> Array.toList
|> FakeExecutionContext.Create false scriptFile
|> RuntimeContext.Fake
|> setExecutionContext

0 comments on commit d3f2de5

Please sign in to comment.