@@ -161,6 +161,9 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
161161let mutable highEntropyVA : bool = false
162162let mutable targetProfile : string = null
163163let mutable dotnetFscCompilerPath : string = null
164+ let mutable skipCompilerExecution : bool = false
165+ let mutable provideCommandLineArgs : bool = false
166+ let mutable commandLineArgs : ITaskItem list = []
164167
165168let mutable capturedArguments : string list = [] // list of individual args, to pass to HostObject Compile()
166169let mutable capturedFilenames : string list = [] // list of individual source filenames, to pass to HostObject Compile()
@@ -500,6 +503,19 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
500503with get() = dotnetFscCompilerPath
501504and set ( p ) = dotnetFscCompilerPath<- p
502505
506+ member fsc.SkipCompilerExecution
507+ with get() = skipCompilerExecution
508+ and set ( p ) = skipCompilerExecution<- p
509+
510+ member fsc.ProvideCommandLineArgs
511+ with get() = provideCommandLineArgs
512+ and set ( p ) = provideCommandLineArgs<- p
513+
514+ [<Output>]
515+ member fsc.CommandLineArgs
516+ with get() = List.toArray commandLineArgs
517+ and set ( p ) = commandLineArgs<- ( List.ofArray p)
518+
503519// ToolTask methods
504520override fsc.ToolName = " fsc.exe"
505521override fsc.StandardErrorEncoding = if utf8outputthen System.Text.Encoding.UTF8else base .StandardErrorEncoding
@@ -513,32 +529,41 @@ type [<Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:Iden
513529
514530/// Intercept the call to ExecuteTool to handle the host compile case.
515531override fsc.ExecuteTool ( pathToTool , responseFileCommands , commandLineCommands ) =
516- let host = box fsc.HostObject
517- match hostwith
518- | null -> base .ExecuteTool( pathToTool, responseFileCommands, commandLineCommands)
519- | _ ->
520- let sources = sources|> Array.map( fun i -> i.ItemSpec)
532+ if provideCommandLineArgsthen
533+ commandLineArgs<-
534+ fsc.GetCapturedArguments()
535+ |> Array.map( fun ( arg : string ) -> TaskItem( arg) :> ITaskItem)
536+ |> Array.toList
537+
538+ if skipCompilerExecutionthen
539+ 0
540+ else
541+ let host = box fsc.HostObject
542+ match hostwith
543+ | null -> base .ExecuteTool( pathToTool, responseFileCommands, commandLineCommands)
544+ | _ ->
545+ let sources = sources|> Array.map( fun i -> i.ItemSpec)
521546#if FX_ NO_ CONVERTER
522- let baseCallDelegate = new Func< int>( fun () -> fsc.BaseExecuteTool( pathToTool, responseFileCommands, commandLineCommands) )
547+ let baseCallDelegate = new Func< int>( fun () -> fsc.BaseExecuteTool( pathToTool, responseFileCommands, commandLineCommands) )
523548#else
524- let baseCall = fun ( dummy : int ) -> fsc.BaseExecuteTool( pathToTool, responseFileCommands, commandLineCommands)
525- // We are using a Converter<int,int> rather than a "unit->int" because it is too hard to
526- // figure out how to pass an F# function object via reflection.
527- let baseCallDelegate = new System.Converter< int, int>( baseCall)
549+ let baseCall = fun ( dummy : int ) -> fsc.BaseExecuteTool( pathToTool, responseFileCommands, commandLineCommands)
550+ // We are using a Converter<int,int> rather than a "unit->int" because it is too hard to
551+ // figure out how to pass an F# function object via reflection.
552+ let baseCallDelegate = new System.Converter< int, int>( baseCall)
528553#endif
529- try
530- let ret =
531- ( host.GetType()) .InvokeMember( " Compile" , BindingFlags.Public||| BindingFlags.NonPublic||| BindingFlags.InvokeMethod||| BindingFlags.Instance, null , host,
532- [| baseCallDelegate; box( capturedArguments|> List.toArray); box( capturedFilenames|> List.toArray) |],
533- System.Globalization.CultureInfo.InvariantCulture)
534- unbox ret
535- with
536- | :? System.Reflection.TargetInvocationExceptionas tiewhen ( match tie.InnerExceptionwith | :? Microsoft.Build.Exceptions.BuildAbortedException-> true | _ -> false ) ->
537- fsc.Log.LogError( tie.InnerException.Message, [| |])
538- - 1 // ok, this is what happens when VS IDE cancels the build, no need to assert, just log the build-canceled error and return -1 to denote task failed
539- | e->
540- System.Diagnostics.Debug.Assert( false , " HostObject received by Fsc task did not have a Compile method or the compile method threw an exception." +( e.ToString()))
541- reraise()
554+ try
555+ let ret =
556+ ( host.GetType()) .InvokeMember( " Compile" , BindingFlags.Public||| BindingFlags.NonPublic||| BindingFlags.InvokeMethod||| BindingFlags.Instance, null , host,
557+ [| baseCallDelegate; box( capturedArguments|> List.toArray); box( capturedFilenames|> List.toArray) |],
558+ System.Globalization.CultureInfo.InvariantCulture)
559+ unbox ret
560+ with
561+ | :? System.Reflection.TargetInvocationExceptionas tiewhen ( match tie.InnerExceptionwith | :? Microsoft.Build.Exceptions.BuildAbortedException-> true | _ -> false ) ->
562+ fsc.Log.LogError( tie.InnerException.Message, [| |])
563+ - 1 // ok, this is what happens when VS IDE cancels the build, no need to assert, just log the build-canceled error and return -1 to denote task failed
564+ | e->
565+ System.Diagnostics.Debug.Assert( false , " HostObject received by Fsc task did not have a Compile method or the compile method threw an exception." +( e.ToString()))
566+ reraise()
542567
543568override fsc.GenerateCommandLineCommands () =
544569let builder = new FscCommandLineBuilder()