From 9f1f7bb20942f5c20b5d35eb806479d8c1929237 Mon Sep 17 00:00:00 2001 From: Cameron Taggart Date: Tue, 30 May 2023 12:02:35 +1000 Subject: [PATCH] add Context.setExecutionContextFromCommandLineArgs --- src/app/Fake.Core.Context/Context.fs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/app/Fake.Core.Context/Context.fs b/src/app/Fake.Core.Context/Context.fs index 62bb790921d..561a3edf39c 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