diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 18e726cfaba..2d3708b7866 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -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. diff --git a/src/app/Fake.Core.Context/Context.fs b/src/app/Fake.Core.Context/Context.fs index 62bb790921d..9687364a871 100644 --- a/src/app/Fake.Core.Context/Context.fs +++ b/src/app/Fake.Core.Context/Context.fs @@ -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 + + /// + /// Creates and sets the FAKE execution context from command line arguments. + /// + let setExecutionContextFromCommandLineArgs scriptFile : unit = + System.Environment.GetCommandLineArgs() + |> Array.skip 2 // skip fsi & scriptFile + |> Array.toList + |> FakeExecutionContext.Create false scriptFile + |> RuntimeContext.Fake + |> setExecutionContext