Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSBuildHelper: new property ToolPath #1703

Merged
merged 1 commit into from
Oct 28, 2017
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
26 changes: 18 additions & 8 deletions src/app/Fake.DotNet.MsBuild/MsBuild.fs
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,15 @@ type MSBuildDistributedLoggerConfig =

/// A type for MSBuild task parameters
type MSBuildParams =
{ Targets : string list
{
/// Set the MSBuild executable to use. Defaults to the latest installed MSBuild.
ToolPath : string
Targets : string list
Properties : (string * string) list
/// corresponds to the msbuild option '/m':
/// - 'None' will omit the option.
/// - 'Some None' will emit '/m'.
/// - 'Some 2' will emit '/m:2'.
MaxCpuCount : int option option
NoLogo : bool
NodeReuse : bool
Expand All @@ -243,13 +250,16 @@ type MSBuildParams =
Verbosity : MSBuildVerbosity option
NoConsoleLogger : bool
WarnAsError: string list option
/// corresponds to the msbuild option '/fl'
FileLoggers : MSBuildFileLoggerConfig list option
/// corresponds to the msbuild option '/bl'
BinaryLoggers : string list option
/// corresponds to the msbuild option '/dl'
DistributedLoggers : (MSBuildDistributedLoggerConfig * MSBuildDistributedLoggerConfig option) list option }

/// Defines a default for MSBuild task parameters
let mutable MSBuildDefaults =
{ Targets = []
{ ToolPath = msBuildExe
Targets = []
Properties = []
MaxCpuCount = Some None
NoLogo = false
Expand Down Expand Up @@ -447,22 +457,22 @@ match BuildServer.buildServer with
/// |> DoNothing
let build setParams project =
use t = Trace.traceTask "MSBuild" project
let args =
let msBuildParams =
MSBuildDefaults
|> setParams
|> serializeMSBuildParams
let argsString = msBuildParams |> serializeMSBuildParams

let errorLoggerParam =
MSBuildLoggers
|> List.map (fun a -> Some ("logger", a))
|> serializeArgs

let args = Process.toParam project + " " + args + " " + errorLoggerParam
Trace.tracefn "Building project: %s\n %s %s" project msBuildExe args
let args = Process.toParam project + " " + argsString + " " + errorLoggerParam
Trace.tracefn "Building project: %s\n %s %s" project msBuildParams.ToolPath args
let exitCode =
Process.ExecProcess (fun info ->
{ info with
FileName = msBuildExe
FileName = msBuildParams.ToolPath
Arguments = args}) TimeSpan.MaxValue
if exitCode <> 0 then
let errors =
Expand Down
27 changes: 20 additions & 7 deletions src/app/FakeLib/MSBuildHelper.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[<AutoOpen>]
[<System.Obsolete("Use Fake.DotNet.MsBuild instead")>]
/// Contains tasks which allow to use MSBuild (or xBuild on Linux/Unix) to build .NET project files or solution files.
module Fake.MSBuildHelper

Expand Down Expand Up @@ -217,8 +218,15 @@ type MSBuildDistributedLoggerConfig =
/// A type for MSBuild task parameters
[<CLIMutable>]
type MSBuildParams =
{ Targets : string list
{
/// Set the MSBuild executable to use. Defaults to the latest installed MSBuild.
ToolPath : string
Targets : string list
Properties : (string * string) list
/// corresponds to the msbuild option '/m':
/// - 'None' will omit the option.
/// - 'Some None' will emit '/m'.
/// - 'Some 2' will emit '/m:2'.
MaxCpuCount : int option option
NoLogo : bool
NodeReuse : bool
Expand All @@ -227,13 +235,17 @@ type MSBuildParams =
Verbosity : MSBuildVerbosity option
NoConsoleLogger : bool
WarnAsError: string list option
/// corresponds to the msbuild option '/fl'
FileLoggers : MSBuildFileLoggerConfig list option
/// corresponds to the msbuild option '/bl'
BinaryLoggers : string list option
/// corresponds to the msbuild option '/dl'
DistributedLoggers : (MSBuildDistributedLoggerConfig * MSBuildDistributedLoggerConfig option) list option }

/// Defines a default for MSBuild task parameters
let mutable MSBuildDefaults =
{ Targets = []
{ ToolPath = msBuildExe
Targets = []
Properties = []
MaxCpuCount = Some None
NoLogo = false
Expand Down Expand Up @@ -429,23 +441,24 @@ match buildServer with
/// |> DoNothing
let build setParams project =
use __ = traceStartTaskUsing "MSBuild" project
let args =
let msBuildParams =
MSBuildDefaults
|> setParams
|> serializeMSBuildParams

let argsString = msBuildParams |> serializeMSBuildParams

let errorLoggerParam =
MSBuildLoggers
|> List.map (fun a -> Some ("logger", a))
|> serializeArgs

let args = toParam project + " " + args + " " + errorLoggerParam
tracefn "Building project: %s\n %s %s" project msBuildExe args
let args = toParam project + " " + argsString + " " + errorLoggerParam
tracefn "Building project: %s\n %s %s" project msBuildParams.ToolPath args
let enableProcessTracingPreviousValue = enableProcessTracing
enableProcessTracing <- false
let exitCode =
ExecProcess (fun info ->
info.FileName <- msBuildExe
info.FileName <- msBuildParams.ToolPath
info.Arguments <- args) TimeSpan.MaxValue
enableProcessTracing <- enableProcessTracingPreviousValue
if exitCode <> 0 then
Expand Down