Skip to content

Commit 79ec1be

Browse files
webwarrior-wsknocte
authored andcommitted
Fsdk/Misc: workaround in FsxOnlyArguments
Filter out `preferreduilang` argument from script args in FsxOnlyArguments() function. This argument started to appear in .NET 10 when running .fsx scripts, breaking existing scripts. It was then removed from fsi.CommandLineArgs, but not from Environment.GetCommandLineArgs(), see [1]. Value fsi.CommandLineArgs can't be used in the library, as it is only available in fsx scripts. [1] dotnet/fsharp#19151
1 parent 5bca818 commit 79ec1be

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/Fsdk/Misc.fs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,22 @@ module Misc =
9595
#endif
9696

9797
let FsxOnlyArguments() =
98-
let cmdLineArgs = Environment.GetCommandLineArgs() |> List.ofSeq
98+
let cmdLineArgs =
99+
Environment.GetCommandLineArgs()
100+
// Filter out preferreduilang from script args, see https://github.com/dotnet/fsharp/pull/19151
101+
|> Seq.filter(fun arg ->
102+
not(
103+
arg.StartsWith(
104+
"--preferreduilang:",
105+
StringComparison.OrdinalIgnoreCase
106+
)
107+
|| arg.StartsWith(
108+
"/preferreduilang:",
109+
StringComparison.OrdinalIgnoreCase
110+
)
111+
)
112+
)
113+
|> List.ofSeq
99114
#if !LEGACY_FRAMEWORK
100115
if cmdLineArgs.Length = 0 then
101116
failwith

0 commit comments

Comments
 (0)