@@ -325,14 +325,51 @@ let main argv = 0"""
325325 compileCompilation ignoreWarnings cmpl ( fun (( errors , _ ), _ ) ->
326326 assertErrors ignoreWarnings errors))
327327
328- static member Execute ( cmpl : Compilation , ? ignoreWarnings , ? beforeExecute ) =
328+ static member Execute ( cmpl : Compilation , ? ignoreWarnings , ? beforeExecute , ? newProcess ) =
329329 let ignoreWarnings = defaultArg ignoreWarnings false
330330 let beforeExecute = defaultArg beforeExecute ( fun _ _ -> ())
331+ let newProcess = defaultArg newProcess false
331332 lock gate ( fun () ->
332333 compileCompilation ignoreWarnings cmpl ( fun (( errors , outputFilePath ), deps ) ->
333334 assertErrors ignoreWarnings errors
334335 beforeExecute outputFilePath deps
335- executeBuiltApp outputFilePath deps))
336+ if newProcess then
337+ let mutable pinfo = ProcessStartInfo()
338+ pinfo.RedirectStandardError <- true
339+ pinfo.RedirectStandardOutput <- true
340+ #if ! NETCOREAPP
341+ pinfo.FileName <- outputFilePath
342+ #else
343+ pinfo.FileName <- " dotnet"
344+ pinfo.Arguments <- outputFilePath
345+
346+ let runtimeconfig =
347+ """
348+ {
349+ "runtimeOptions": {
350+ "tfm": "netcoreapp3.1",
351+ "framework": {
352+ "name": "Microsoft.NETCore.App",
353+ "version": "3.1.0"
354+ }
355+ }
356+ }
357+ """
358+
359+ let runtimeconfigPath = Path.ChangeExtension( outputFilePath, " .runtimeconfig.json" )
360+ File.WriteAllText( runtimeconfigPath, runtimeconfig)
361+ use _ disposal =
362+ { new IDisposable with
363+ member _. Dispose() = try File.Delete runtimeconfigPath with | _ -> () }
364+ #endif
365+ pinfo.UseShellExecute <- false
366+ let p = Process.Start pinfo
367+ let errors = p.StandardError.ReadToEnd()
368+ Assert.True( p.WaitForExit( 120000 ))
369+ if p.ExitCode <> 0 then
370+ Assert.Fail errors
371+ else
372+ executeBuiltApp outputFilePath deps))
336373
337374 static member Pass ( source : string ) =
338375 lock gate <| fun () ->
0 commit comments