@@ -268,15 +268,23 @@ let AdjustForScriptCompile (tcConfigB: TcConfigBuilder, commandLineSourceFiles,
268
268
269
269
List.rev allSources
270
270
271
- let SetProcessThreadLocals tcConfigB =
271
+ let SetProcessThreadLocals tcConfigB ( disposables : DisposablesTracker ) =
272
272
match tcConfigB.preferredUiLang with
273
273
| Some s -> Thread.CurrentThread.CurrentUICulture <- CultureInfo( s)
274
274
| None -> ()
275
275
276
276
if tcConfigB.utf8output then
277
+ let originalEncoding = Console.OutputEncoding
277
278
Console.OutputEncoding <- Encoding.UTF8
278
279
279
- let ProcessCommandLineFlags ( tcConfigB : TcConfigBuilder , lcidFromCodePage , argv ) =
280
+ disposables.Register(
281
+ { new IDisposable with
282
+ member _. Dispose() =
283
+ Console.OutputEncoding <- originalEncoding
284
+ }
285
+ )
286
+
287
+ let ProcessCommandLineFlags ( tcConfigB : TcConfigBuilder , lcidFromCodePage , argv , disposables ) =
280
288
let mutable inputFilesRef = []
281
289
282
290
let collect name =
@@ -297,7 +305,7 @@ let ProcessCommandLineFlags (tcConfigB: TcConfigBuilder, lcidFromCodePage, argv)
297
305
| Some _ -> ()
298
306
| None -> tcConfigB.lcid <- lcidFromCodePage
299
307
300
- SetProcessThreadLocals tcConfigB
308
+ SetProcessThreadLocals tcConfigB disposables
301
309
302
310
(* step - get dll references *)
303
311
let dllFiles , sourceFiles =
@@ -535,7 +543,7 @@ let main1
535
543
// The ParseCompilerOptions function calls imperative function to process "real" args
536
544
// Rather than start processing, just collect names, then process them.
537
545
try
538
- let files = ProcessCommandLineFlags( tcConfigB, lcidFromCodePage, argv)
546
+ let files = ProcessCommandLineFlags( tcConfigB, lcidFromCodePage, argv, disposables )
539
547
let files = CheckAndReportSourceFileDuplicates( ResizeArray.ofList files)
540
548
AdjustForScriptCompile( tcConfigB, files, lexResourceManager, dependencyProvider)
541
549
with e ->
0 commit comments