Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/Fable.Compiler/MSBuildCrackerResolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ module private MSBuildCrackerResolver =

type FullPath = string

[<Literal>]
let private TelemetryOptOutVariable = "DOTNET_CLI_TELEMETRY_OPTOUT"

let private run_dotnet_msbuild (cwd: string) (fsproj: FullPath) (args: string) (defines: string list) =
backgroundTask {
let psi = ProcessStartInfo "dotnet"
Expand All @@ -52,9 +49,8 @@ module private MSBuildCrackerResolver =
// https://github.com/fable-compiler/Fable/issues/4014
psi.Environment.Add("DOTNET_NOLOGO", "1")

// The dotnet CLI blocks on sending telemetry at exit, which can take seconds on a restricted network
if not (psi.Environment.ContainsKey TelemetryOptOutVariable) then
psi.Environment.Add(TelemetryOptOutVariable, "1")
for key, value in Fable.Compiler.Util.Process.dotnetEnvVars () do
psi.Environment[key] <- value

if not (List.isEmpty defines) then
let definesValue = defines |> String.concat ";"
Expand Down
6 changes: 5 additions & 1 deletion src/Fable.Compiler/ProjectCracker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ type CrackerOptions(cliArgs: CliArgs, evaluateOnly: bool) =

pendingDllBuilds[normalizedDllPath] <-
Task.Run(fun () ->
Process.runSyncWithOutput projDir "dotnet" [ "build"; "-c"; cliArgs.Configuration; "--no-restore" ]
Process.runSyncWithOutputEnv
(Process.dotnetEnvVars ())
projDir
"dotnet"
[ "build"; "-c"; cliArgs.Configuration; "--no-restore" ]
)

member _.WaitForBuiltDlls() =
Expand Down
15 changes: 13 additions & 2 deletions src/Fable.Compiler/Util.fs
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,24 @@ module Process =
let runSync (workingDir: string) (exePath: string) (args: string list) =
runSyncWithEnv [] workingDir exePath args

let runSyncWithOutput workingDir exePath args =
let p = startProcess true [] workingDir exePath args
/// Environment for the `dotnet` processes Fable starts for itself, not for the user's --run commands
let dotnetEnvVars () =
// The dotnet CLI blocks on sending telemetry at exit, which can take seconds on a restricted network
if isNull (Environment.GetEnvironmentVariable "DOTNET_CLI_TELEMETRY_OPTOUT") then
[ "DOTNET_CLI_TELEMETRY_OPTOUT", "1" ]
else
[]

let runSyncWithOutputEnv envVars workingDir exePath args =
let p = startProcess true envVars workingDir exePath args
// Don't wait indefinitely to run process
// This call is used to build local plugins, if the binary is used by another process this process will never end.
p.WaitForExit 7000 |> ignore
p.StandardOutput.ReadToEnd()

let runSyncWithOutput workingDir exePath args =
runSyncWithOutputEnv [] workingDir exePath args

[<RequireQualifiedAccess>]
module Async =
let fold f (state: 'State) (xs: 'T seq) =
Expand Down
5 changes: 5 additions & 0 deletions src/Fable.Compiler/Util.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ module Process =

val runSyncWithOutput: string -> string -> string list -> string

val runSyncWithOutputEnv: envVars: (string * string) list -> string -> string -> string list -> string

/// Environment for the `dotnet` processes Fable starts for itself, not for the user's --run commands
val dotnetEnvVars: unit -> (string * string) list

type PathResolver =
abstract TryPrecompiledOutPath: sourceDir: string * relativePath: string -> string option

Expand Down
Loading