From 187466b687929550914de0c9a39486844e3a7815 Mon Sep 17 00:00:00 2001 From: Jarno Nijboer Date: Tue, 27 Mar 2018 20:33:30 +0200 Subject: [PATCH 1/4] Fix inconsistent naming of MSBuild package, add setParams to run* methods --- src/app/Fake.BuildServer.TeamCity/TeamCity.fs | 13 +-- src/app/Fake.Core.Environment/BuildServer.fs | 16 +--- .../AssemblyInfo.fs | 0 .../Fake.DotNet.MSBuild.fsproj} | 6 +- .../MSBuild.fs} | 93 +++++++++++-------- .../MSBuildLogger.fs} | 35 ++++--- .../paket.references | 0 7 files changed, 81 insertions(+), 82 deletions(-) rename src/app/{Fake.DotNet.MsBuild => Fake.DotNet.MSBuild}/AssemblyInfo.fs (100%) rename src/app/{Fake.DotNet.MsBuild/Fake.DotNet.MsBuild.fsproj => Fake.DotNet.MSBuild/Fake.DotNet.MSBuild.fsproj} (90%) rename src/app/{Fake.DotNet.MsBuild/MsBuild.fs => Fake.DotNet.MSBuild/MSBuild.fs} (88%) rename src/app/{Fake.DotNet.MsBuild/MsBuildLogger.fs => Fake.DotNet.MSBuild/MSBuildLogger.fs} (76%) rename src/app/{Fake.DotNet.MsBuild => Fake.DotNet.MSBuild}/paket.references (100%) diff --git a/src/app/Fake.BuildServer.TeamCity/TeamCity.fs b/src/app/Fake.BuildServer.TeamCity/TeamCity.fs index 93cf10d545f..c7043196816 100644 --- a/src/app/Fake.BuildServer.TeamCity/TeamCity.fs +++ b/src/app/Fake.BuildServer.TeamCity/TeamCity.fs @@ -2,9 +2,7 @@ namespace Fake.BuildServer open System -open System.IO open Fake.Core -open Fake.IO [] module TeamCityImportExtensions = @@ -51,9 +49,6 @@ module TeamCity = let internal sendTeamCityImportData typ file = TeamCityWriter.sendToTeamCity2 "##teamcity[importData type='%s' file='%s']" typ file - - - module internal Import = /// Sends an NUnit results filename to TeamCity let sendNUnit path = sendTeamCityImportData "nunit" path @@ -150,14 +145,14 @@ module TeamCity = /// Report Standard-Output for a given test-case let internal reportTestOutput name output = - sprintf "##teamcity[testStdOut name='%s' out='%s']" + sprintf "##teamcity[testStdOut name='%s' out='%s']" (TeamCityWriter.encapsulateSpecialChars name) (TeamCityWriter.encapsulateSpecialChars output) |> TeamCityWriter.sendStrToTeamCity /// Report Standard-Error for a given test-case let internal reportTestError name output = - sprintf "##teamcity[testStdErr name='%s' out='%s']" + sprintf "##teamcity[testStdErr name='%s' out='%s']" (TeamCityWriter.encapsulateSpecialChars name) (TeamCityWriter.encapsulateSpecialChars output) |> TeamCityWriter.sendStrToTeamCity @@ -247,7 +242,7 @@ module TeamCity = interface ITraceListener with /// Writes the given message to the Console. - member __.Write msg = + member __.Write msg = let color = ConsoleWriter.colorMap msg match msg with | TraceData.OpenTag (KnownTags.Test name, _) -> @@ -291,7 +286,7 @@ module TeamCity = if not (detect()) then failwithf "Cannot run 'install()' on a non-TeamCity environment" if force || not (CoreTracing.areListenersSet()) then CoreTracing.setTraceListeners [defaultTraceListener] - () + () let Installer = { new BuildServerInstaller() with member __.Install () = install (false) diff --git a/src/app/Fake.Core.Environment/BuildServer.fs b/src/app/Fake.Core.Environment/BuildServer.fs index 7cee2be3191..7893fcb9d5a 100644 --- a/src/app/Fake.Core.Environment/BuildServer.fs +++ b/src/app/Fake.Core.Environment/BuildServer.fs @@ -17,7 +17,7 @@ type BuildServer = | LocalBuild /// The trace mode option. -type TraceMode = +type TraceMode = | Console | Xml @@ -32,7 +32,7 @@ module BuildServer = let mutable verbose = hasEnvironVar "verbose" /// A constant label for local builds - /// [omit] + /// [omit] let localBuildLabel = "LocalBuild" /// Defines the XML output file - used for build servers like CruiseControl.NET. @@ -87,7 +87,7 @@ module BuildServer = let appVeyorBuildVersion = environVar "APPVEYOR_BUILD_VERSION" /// The current build server - let buildServer = + let buildServer = if hasEnvironVar "JENKINS_HOME" then Jenkins elif hasEnvironVar "TEAMCITY_VERSION" then TeamCity elif not (String.IsNullOrEmpty ccBuildLabel) then CCNet @@ -100,7 +100,7 @@ module BuildServer = else LocalBuild /// The current build version as detected from the current build server. - let buildVersion = + let buildVersion = let getVersion = environVarOrDefault "buildVersion" match buildServer with | Jenkins -> getVersion jenkinsBuildNumber @@ -120,12 +120,6 @@ module BuildServer = let install (servers: BuildServerInstaller list) = servers - |> List.iter (fun f -> + |> List.iter (fun f -> if f.Detect() then f.Install()) - - - -//open Fake.Core - -//BuildServer.Configure [ TeamCity.Configuration; AppVeyor.Configuration; Travis.Configuration ] \ No newline at end of file diff --git a/src/app/Fake.DotNet.MsBuild/AssemblyInfo.fs b/src/app/Fake.DotNet.MSBuild/AssemblyInfo.fs similarity index 100% rename from src/app/Fake.DotNet.MsBuild/AssemblyInfo.fs rename to src/app/Fake.DotNet.MSBuild/AssemblyInfo.fs diff --git a/src/app/Fake.DotNet.MsBuild/Fake.DotNet.MsBuild.fsproj b/src/app/Fake.DotNet.MSBuild/Fake.DotNet.MSBuild.fsproj similarity index 90% rename from src/app/Fake.DotNet.MsBuild/Fake.DotNet.MsBuild.fsproj rename to src/app/Fake.DotNet.MSBuild/Fake.DotNet.MSBuild.fsproj index 30595572166..332b65b82c4 100644 --- a/src/app/Fake.DotNet.MsBuild/Fake.DotNet.MsBuild.fsproj +++ b/src/app/Fake.DotNet.MSBuild/Fake.DotNet.MSBuild.fsproj @@ -2,7 +2,7 @@ net46;netstandard1.6;netstandard2.0 $(DefineConstants);DOTNETCORE - Fake.DotNet.MsBuild + Fake.DotNet.MSBuild Library @@ -21,8 +21,8 @@ - - + + \ No newline at end of file diff --git a/src/app/Fake.DotNet.MsBuild/MsBuild.fs b/src/app/Fake.DotNet.MSBuild/MSBuild.fs similarity index 88% rename from src/app/Fake.DotNet.MsBuild/MsBuild.fs rename to src/app/Fake.DotNet.MSBuild/MSBuild.fs index b5e24080e19..259485694d4 100644 --- a/src/app/Fake.DotNet.MsBuild/MsBuild.fs +++ b/src/app/Fake.DotNet.MSBuild/MSBuild.fs @@ -18,7 +18,7 @@ exception BuildException of string*list with override x.ToString() = x.Data0.ToString() + "\r\n" + (String.separated "\r\n" x.Data1) -type MsBuildEntry = { +type MSBuildEntry = { Version: string; Paths: string list; } @@ -62,8 +62,8 @@ type MSBuildDistributedLoggerConfig = AssemblyPath : string Parameters : (string * string) list option } -module private MsBuildExe = - let knownMsBuildEntries = +module private MSBuildExe = + let knownMSBuildEntries = [ { Version = "15.0"; Paths = [@"\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin" @"\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin" @@ -74,7 +74,7 @@ module private MsBuildExe = { Version = "12.0"; Paths = [@"\MSBuild\12.0\Bin"; @"\MSBuild\12.0\Bin\amd64"] } ] - let oldMsBuildLocations = + let oldMSBuildLocations = [ @"c:\Windows\Microsoft.NET\Framework\v4.0.30319\"; @"c:\Windows\Microsoft.NET\Framework\v4.0.30128\"; @"c:\Windows\Microsoft.NET\Framework\v3.5\" @@ -84,7 +84,7 @@ module private MsBuildExe = items |> Seq.map (fun f -> f.Version, f.Paths) |> Map.ofSeq let private getAllKnownPaths = - (knownMsBuildEntries |> List.collect (fun m -> m.Paths)) @ oldMsBuildLocations + (knownMSBuildEntries |> List.collect (fun m -> m.Paths)) @ oldMSBuildLocations /// Versions of Mono prior to this one have faulty implementations of MSBuild /// NOTE: in System.Version 5.0 >= 5.0.0.0 is false while 5.0.0.0 >= 5.0 is true... @@ -120,20 +120,20 @@ module private MsBuildExe = let which tool = Process.tryFindFileOnPath tool let msbuildEnvironVar = Environment.environVarOrNone "MSBuild" - let preferMsBuildOnNetCore = + let preferMSBuildOnNetCore = if not Environment.isUnix || Environment.isMono then false else match Mono.monoVersion with | Some(_, Some(version)) when version >= monoVersionToUseMSBuildOn -> true | _ -> false - let preferMsBuildOnMono = + let preferMSBuildOnMono = match Environment.monoVersion with | Some(_, Some(version)) when version >= monoVersionToUseMSBuildOn -> true | _ -> false let foundExe = - match Environment.isUnix, preferMsBuildOnNetCore || preferMsBuildOnMono with + match Environment.isUnix, preferMSBuildOnNetCore || preferMSBuildOnMono with | true, true -> let sources = [ msbuildEnvironVar |> Option.map (exactPathOrBinaryOnPath "msbuild") @@ -160,7 +160,7 @@ module private MsBuildExe = #endif None let findOnVSPathsThenSystemPath = - let dict = toDict knownMsBuildEntries + let dict = toDict knownMSBuildEntries let vsVersionPaths = defaultArg (Environment.environVarOrNone "VisualStudioVersion" |> Option.bind dict.TryFind) getAllKnownPaths |> List.map ((@@) Environment.ProgramFilesX86) @@ -209,7 +209,7 @@ type MSBuildParams = Environment : Map } /// Defines a default for MSBuild task parameters static member Create() = - { ToolPath = MsBuildExe.msBuildExe + { ToolPath = MSBuildExe.msBuildExe Targets = [] Properties = [] MaxCpuCount = Some None @@ -227,7 +227,7 @@ type MSBuildParams = Process.createEnvironmentMap() |> Map.remove "MSBUILD_EXE_PATH" |> Map.remove "MSBuildExtensionsPath" } - [] + [] static member Empty = MSBuildParams.Create() /// Sets the current environment variables. @@ -235,16 +235,16 @@ type MSBuildParams = { x with Environment = map } [] -module MsBuild = +module MSBuild = - let msBuildExe = MsBuildExe.msBuildExe + let msBuildExe = MSBuildExe.msBuildExe /// [omit] let msbuildNamespace = "http://schemas.microsoft.com/developer/msbuild/2003" /// [omit] let xname name = XName.Get(name, msbuildNamespace) - + /// [omit] let loadProject (projectFileName : string) : MSBuildProject = MSBuildProject.Load(projectFileName, LoadOptions.PreserveWhitespace) @@ -394,7 +394,7 @@ module MsBuild = | None -> "" | Some ps -> ps - |> List.map (fun p -> sprintf "%s;" (logParams p)) + |> List.map (logParams >> (sprintf "%s")) |> String.concat "") match p.FileLoggers with @@ -438,8 +438,8 @@ module MsBuild = #if !NO_MSBUILD_AVAILABLE /// [omit] - let ErrorLoggerName = typedefof.FullName - + let ErrorLoggerName = typedefof.FullName + let private pathToLogger = typedefof.Assembly.Location #endif @@ -459,7 +459,7 @@ module MsBuild = /// Runs a MSBuild project /// ## Parameters - /// - `setParams` - A function that overwrites the default MsBuildParams + /// - `setParams` - A function that overwrites the default MSBuildParams /// - `project` - A string with the path to the project file to build. /// /// ## Sample @@ -477,7 +477,7 @@ module MsBuild = /// "Configuration", buildMode /// ] /// } - /// MsBuild.build setParams "./MySolution.sln" + /// MSBuild.build setParams "./MySolution.sln" let build setParams project = use __ = Trace.traceTask "MSBuild" project let msBuildParams = @@ -502,8 +502,8 @@ module MsBuild = let errors = System.Threading.Thread.Sleep(200) // wait for the file to write #if !NO_MSBUILD_AVAILABLE - if File.Exists MsBuildLogger.ErrorLoggerFile then - File.ReadAllLines(MsBuildLogger.ErrorLoggerFile) |> List.ofArray + if File.Exists MSBuildLogger.ErrorLoggerFile then + File.ReadAllLines(MSBuildLogger.ErrorLoggerFile) |> List.ofArray else [] #else [] @@ -514,19 +514,20 @@ module MsBuild = /// Builds the given project files and collects the output files. /// ## Parameters + /// - `setParams` - A function that overwrites the default MSBuildParams /// - `outputPath` - If it is null or empty then the project settings are used. /// - `targets` - A string with the target names which should be run by MSBuild. /// - `properties` - A list with tuples of property name and property values. /// - `projects` - A list of project or solution files. - let runWithProperties outputPath (targets : string) (properties : (string) -> (string * string) list) projects = + let runWithProperties setParams outputPath (targets : string) (properties : (string) -> (string * string) list) projects = let projects = projects |> Seq.toList let output = if String.isNullOrEmpty outputPath then "" else - outputPath - |> Path.getFullName - |> String.trimSeparator + outputPath + |> Path.getFullName + |> String.trimSeparator let properties = if String.isNullOrEmpty output then properties @@ -534,11 +535,15 @@ module MsBuild = let dependencies = projects - |> List.map getProjectReferences - |> Set.unionMany + |> List.map getProjectReferences + |> Set.unionMany - let setBuildParam project projectParams = - { projectParams with Targets = targets |> String.split ';' |> List.filter ((<>) ""); Properties = projectParams.Properties @ properties project } + let setBuildParam project defaultParams = + let projectParams = setParams defaultParams + let targets = targets |> String.split ';' |> List.filter String.isNotNullOrEmpty + { projectParams with + Targets = projectParams.Targets @ targets + Properties = projectParams.Properties @ properties project } projects |> List.filter (fun project -> not <| Set.contains project dependencies) @@ -549,48 +554,53 @@ module MsBuild = /// Builds the given project files or solution files and collects the output files. /// ## Parameters + /// - `setParams` - A function that overwrites the default MSBuildParams /// - `outputPath` - If it is null or empty then the project settings are used. /// - `targets` - A string with the target names which should be run by MSBuild. /// - `properties` - A list with tuples of property name and property values. /// - `projects` - A list of project or solution files. - let run outputPath targets properties projects = runWithProperties outputPath targets (fun _ -> properties) projects + let run setParams outputPath targets properties projects = runWithProperties setParams outputPath targets (fun _ -> properties) projects /// Builds the given project files or solution files and collects the output files. /// ## Parameters + /// - `setParams` - A function that overwrites the default MSBuildParams /// - `outputPath` - If it is null or empty then the project settings are used. /// - `targets` - A string with the target names which should be run by MSBuild. /// - `projects` - A list of project or solution files. - let runDebug outputPath targets projects = run outputPath targets [ "Configuration", "Debug" ] projects + let runDebug setParams outputPath targets projects = run setParams outputPath targets [ "Configuration", "Debug" ] projects /// Builds the given project files or solution files and collects the output files. /// ## Parameters + /// - `setParams` - A function that overwrites the default MSBuildParams /// - `outputPath` - If it is null or empty then the project settings are used. /// - `targets` - A string with the target names which should be run by MSBuild. /// - `projects` - A list of project or solution files. - let runRelease outputPath targets projects = run outputPath targets [ "Configuration", "Release" ] projects + let runRelease setParams outputPath targets projects = run setParams outputPath targets [ "Configuration", "Release" ] projects /// Builds the given project files or solution files in release mode to the default outputs. /// ## Parameters /// - `targets` - A string with the target names which should be run by MSBuild. /// - `projects` - A list of project or solution files. - let runWithDefaults targets projects = run null targets [ "Configuration", "Release" ] projects + let runWithDefaults targets projects = run id null targets [ "Configuration", "Release" ] projects /// Builds the given project files or solution files in release mode and collects the output files. /// ## Parameters + /// - `setParams` - A function that overwrites the default MSBuildParams /// - `outputPath` - If it is null or empty then the project settings are used. /// - `properties` - A list with tuples of property name and property values. /// - `targets` - A string with the target names which should be run by MSBuild. /// - `projects` - A list of project or solution files. - let runReleaseExt outputPath properties targets projects = + let runReleaseExt setParams outputPath properties targets projects = let properties = ("Configuration", "Release") :: properties - run outputPath targets properties projects + run setParams outputPath targets properties projects /// Builds the given web project file in the specified configuration and copies it to the given outputPath. /// ## Parameters + /// - `setParams` - A function that overwrites the default MSBuildParams /// - `outputPath` - The output path. /// - `configuration` - MSBuild configuration. /// - `projectFile` - The project file path. - let buildWebsiteConfig outputPath configuration projectFile = + let buildWebsiteConfig setParams outputPath configuration projectFile = use t = Trace.traceTask "BuildWebsite" projectFile let projectName = (FileInfo.ofPath projectFile).Name.Replace(".csproj", "").Replace(".fsproj", "").Replace(".vbproj", "") @@ -607,8 +617,8 @@ module MsBuild = then "" else (String.replicate diff "../") - run null "Build" [ "Configuration", configuration ] [ projectFile ] |> ignore - run null "_CopyWebApplication;_BuiltWebOutputGroupOutput" + run setParams null "Build" [ "Configuration", configuration ] [ projectFile ] |> ignore + run setParams null "_CopyWebApplication;_BuiltWebOutputGroupOutput" [ "Configuration", configuration "OutDir", prefix + outputPath "WebProjectOutputDir", prefix + outputPath + "/" + projectName ] [ projectFile ] @@ -619,15 +629,16 @@ module MsBuild = /// ## Parameters /// - `outputPath` - The output path. /// - `projectFile` - The project file path. - let buildWebsite outputPath projectFile = buildWebsiteConfig outputPath "Debug" projectFile + let buildWebsite outputPath projectFile = buildWebsiteConfig id outputPath "Debug" projectFile /// Builds the given web project files in specified configuration and copies them to the given outputPath. /// ## Parameters + /// - `setParams` - A function that overwrites the default MSBuildParams /// - `outputPath` - The output path. /// - `configuration` - MSBuild configuration. /// - `projectFiles` - The project file paths. - let buildWebsitesConfig outputPath configuration projectFiles = Seq.iter (buildWebsiteConfig outputPath configuration) projectFiles - + let buildWebsitesConfig setParams outputPath configuration projectFiles = Seq.iter (buildWebsiteConfig setParams outputPath configuration) projectFiles + /// Builds the given web project files with debug configuration and copies them to the given websiteDir. /// ## Parameters /// - `outputPath` - The output path. diff --git a/src/app/Fake.DotNet.MsBuild/MsBuildLogger.fs b/src/app/Fake.DotNet.MSBuild/MSBuildLogger.fs similarity index 76% rename from src/app/Fake.DotNet.MsBuild/MsBuildLogger.fs rename to src/app/Fake.DotNet.MSBuild/MSBuildLogger.fs index 5f0fb830918..ad760898dbf 100644 --- a/src/app/Fake.DotNet.MsBuild/MsBuildLogger.fs +++ b/src/app/Fake.DotNet.MSBuild/MSBuildLogger.fs @@ -1,7 +1,6 @@ -/// Contains Logger implementations for MsBuild. -module Fake.DotNet.MsBuildLogger +/// Contains Logger implementations for MSBuild. +module Fake.DotNet.MSBuildLogger -open Fake.IO #if !NO_MSBUILD_AVAILABLE open Microsoft.Build open Microsoft.Build.Framework @@ -13,32 +12,32 @@ open System.IO let errToStr (a : BuildErrorEventArgs) = sprintf "%s: %s(%d,%d): %s" a.Code a.File a.LineNumber a.ColumnNumber a.Message /// Abstract MSBuild Logger class. -type MSBuildLogger() = +type MSBuildLogger() = let mutable Verbosity = LoggerVerbosity.Normal let mutable Parameters = "" - + /// Abstract function which registers an event listener. abstract RegisterEvents : IEventSource -> unit - + override t.RegisterEvents e = () interface ILogger with - - member this.Parameters + + member this.Parameters with get () = Parameters and set (value) = Parameters <- value - - member this.Verbosity + + member this.Verbosity with get () = Verbosity and set (value) = Verbosity <- value - + member this.Shutdown() = () member this.Initialize(eventSource) = this.RegisterEvents(eventSource) (* TODO: Add to TeamCity /// TeamCity Logger for MSBuild -type TeamCityLogger() = +type TeamCityLogger() = inherit MSBuildLogger() - override this.RegisterEvents(eventSource) = + override this.RegisterEvents(eventSource) = eventSource.ErrorRaised.Add(fun a -> errToStr a |> TeamCityHelper.sendTeamCityError) *) @@ -46,19 +45,19 @@ type TeamCityLogger() = let ErrorLoggerFile = Path.Combine(Path.GetTempPath(), "Fake.Errors.txt") /// TeamCity Logger for MSBuild -type ErrorLogger() = +type ErrorLogger() = inherit MSBuildLogger() let errors = new List() - override this.RegisterEvents(eventSource) = - eventSource.BuildStarted.Add(fun _ -> + override this.RegisterEvents(eventSource) = + eventSource.BuildStarted.Add(fun _ -> let fi = FileInfo.ofPath ErrorLoggerFile if fi.Exists then fi.Delete()) eventSource.ErrorRaised.Add(fun a -> errors.Add a) - eventSource.BuildFinished.Add(fun a -> + eventSource.BuildFinished.Add(fun a -> errors |> Seq.map errToStr |> fun e -> String.Join(Environment.NewLine, e) - |> fun e -> + |> fun e -> if a.Succeeded then () else File.WriteAllText(ErrorLoggerFile, e)) diff --git a/src/app/Fake.DotNet.MsBuild/paket.references b/src/app/Fake.DotNet.MSBuild/paket.references similarity index 100% rename from src/app/Fake.DotNet.MsBuild/paket.references rename to src/app/Fake.DotNet.MSBuild/paket.references From 8ee64f0f5aecca4758c481abc37120a48fa5b406 Mon Sep 17 00:00:00 2001 From: Jarno Nijboer Date: Wed, 28 Mar 2018 00:17:17 +0200 Subject: [PATCH 2/4] Fix build.fsx --- build.fsx | 14 +++++++------- src/app/Fake.DotNet.MSBuild/MSBuildLogger.fs | 1 + src/app/Fake.DotNet.Xamarin/Xamarin.fs | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/build.fsx b/build.fsx index e0f0b262258..c522cadc416 100644 --- a/build.fsx +++ b/build.fsx @@ -176,7 +176,7 @@ Target.create "Clean" (fun _ -> // Workaround https://github.com/fsprojects/Paket/issues/2830 // https://github.com/fsprojects/Paket/issues/2689 - // Basically paket fails if there is already an existing nuspec in obj/ dir because then MsBuild will call paket with multiple nuspec file arguments separated by ';' + // Basically paket fails if there is already an existing nuspec in obj/ dir because then MSBuild will call paket with multiple nuspec file arguments separated by ';' !! "src/*/*/obj/**/*.nuspec" -- (sprintf "src/*/*/obj/**/*%s.nuspec" release.NugetVersion) //-- "src/*/*/obj/*.references" @@ -267,7 +267,7 @@ let dotnetAssemblyInfos = "Fake.Core.Xml", "Core Xml functionality" "Fake.DotNet.AssemblyInfoFile", "Writing AssemblyInfo files" "Fake.DotNet.Cli", "Running the dotnet cli" - "Fake.DotNet.MsBuild", "Running msbuild" + "Fake.DotNet.MSBuild", "Running msbuild" "Fake.DotNet.NuGet", "Running NuGet Client and interacting with NuGet Feeds" "Fake.DotNet.Paket", "Running Paket and publishing packages" "Fake.DotNet.FSFormatting", "Running fsformatting.exe and generating documentation" @@ -721,10 +721,10 @@ Target.create "DotNetPackage_" (fun _ -> { c with Configuration = DotNet.Release OutputPath = Some nugetDir - Common = + Common = if CircleCi.isCircleCi then { c.Common with CustomParams = Some "/m:1" } - else c.Common + else c.Common } |> dtntSmpl) "Fake.sln" let info = DotNet.info dtntSmpl @@ -956,13 +956,13 @@ Target.create "FastRelease" (fun _ -> | s when not (System.String.IsNullOrWhiteSpace s) -> s | _ -> failwith "please set the github_token environment variable to a github personal access token with repro access." - let files = + let files = runtimes @ [ "portable"; "packages" ] |> List.map (fun n -> sprintf "nuget/dotnetcore/Fake.netcore/fake-dotnetcore-%s.zip" n) - + GitHub.createClientWithToken token |> GitHub.draftNewRelease gitOwner gitName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes - |> GitHub.uploadFiles files + |> GitHub.uploadFiles files |> GitHub.publishDraft |> Async.RunSynchronously ) diff --git a/src/app/Fake.DotNet.MSBuild/MSBuildLogger.fs b/src/app/Fake.DotNet.MSBuild/MSBuildLogger.fs index ad760898dbf..45e3af3ac5e 100644 --- a/src/app/Fake.DotNet.MSBuild/MSBuildLogger.fs +++ b/src/app/Fake.DotNet.MSBuild/MSBuildLogger.fs @@ -7,6 +7,7 @@ open Microsoft.Build.Framework open System open System.Collections.Generic open System.IO +open Fake.IO /// [omit] let errToStr (a : BuildErrorEventArgs) = sprintf "%s: %s(%d,%d): %s" a.Code a.File a.LineNumber a.ColumnNumber a.Message diff --git a/src/app/Fake.DotNet.Xamarin/Xamarin.fs b/src/app/Fake.DotNet.Xamarin/Xamarin.fs index 70c4dd2a768..dbcff42ccf4 100644 --- a/src/app/Fake.DotNet.Xamarin/Xamarin.fs +++ b/src/app/Fake.DotNet.Xamarin/Xamarin.fs @@ -164,7 +164,7 @@ let iOSBuild setParams = msBuildParams let buildProject param = - MsBuild.build (fun msbuildParam -> applyiOSBuildParamsToMSBuildParams param msbuildParam) param.ProjectPath |> ignore + MSBuild.build (fun msbuildParam -> applyiOSBuildParamsToMSBuildParams param msbuildParam) param.ProjectPath |> ignore iOSBuildDefaults |> setParams @@ -272,7 +272,7 @@ let AndroidBuildPackages setParams = result - MsBuild.build (fun msbuildParam -> applyBuildParams msbuildParam) param.ProjectPath |> ignore + MSBuild.build (fun msbuildParam -> applyBuildParams msbuildParam) param.ProjectPath |> ignore let rewriteManifestFile (manifestFile:string) outfile (transformVersion:IncrementerVersion) target = let manifest = XDocument.Load(manifestFile) @@ -291,7 +291,7 @@ let AndroidBuildPackages setParams = |> Seq.last let createPackage param = - MsBuild.build (fun msbuildParam -> applyAndroidBuildParamsToMSBuildParams param msbuildParam) param.ProjectPath |> ignore + MSBuild.build (fun msbuildParam -> applyAndroidBuildParamsToMSBuildParams param msbuildParam) param.ProjectPath |> ignore [ mostRecentFileInDirMatching param.OutputPath ] From dd596ed00bb3c4504f28b310d420648ffbfe464c Mon Sep 17 00:00:00 2001 From: Jarno Nijboer Date: Wed, 28 Mar 2018 08:51:28 +0200 Subject: [PATCH 3/4] Update MsBuild -> MSBuild in docs/tests --- Fake.sln | 2 +- help/markdown/core-targets.md | 20 ++--- help/markdown/dotnet-assemblyinfo.md | 6 +- help/markdown/fake-gettingstarted.md | 20 ++--- help/markdown/legacy-core-targets.md | 34 ++++----- help/templates/template.cshtml | 4 +- .../Fake.DotNet.Xamarin.fsproj | 2 +- src/legacy/FakeLib/FakeLib.fsproj | 8 +- src/legacy/FakeLib/MSBuildHelper.fs | 74 +++++++++---------- src/legacy/FakeLib/MsBuildLogger.fs | 40 +++++----- 10 files changed, 105 insertions(+), 105 deletions(-) diff --git a/Fake.sln b/Fake.sln index 530af044708..fc85cae3663 100644 --- a/Fake.sln +++ b/Fake.sln @@ -28,7 +28,7 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.DotNet.AssemblyInfoFil EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.DotNet.Cli", "src/app/Fake.DotNet.Cli/Fake.DotNet.Cli.fsproj", "{B2C0063A-FC66-4883-BB69-B1DBE6BF9CA2}" EndProject -Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.DotNet.MsBuild", "src/app/Fake.DotNet.MsBuild/Fake.DotNet.MsBuild.fsproj", "{64195C50-E138-4218-A7CE-13CD4565B87E}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.DotNet.MSBuild", "src/app/Fake.DotNet.MSBuild/Fake.DotNet.MSBuild.fsproj", "{64195C50-E138-4218-A7CE-13CD4565B87E}" EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Fake.DotNet.NuGet", "src/app/Fake.DotNet.NuGet/Fake.DotNet.NuGet.fsproj", "{93F1A71E-54E2-4C65-BB1E-1D499890317F}" EndProject diff --git a/help/markdown/core-targets.md b/help/markdown/core-targets.md index 3f15f9dd108..921dafad7d2 100644 --- a/help/markdown/core-targets.md +++ b/help/markdown/core-targets.md @@ -22,15 +22,15 @@ nuget Fake.Core.Target //" open Fake.Core // *** Define Targets *** -Target.create "Clean" (fun _ -> +Target.create "Clean" (fun _ -> Trace.trace " --- Cleaning stuff --- " ) -Target.create "Build" (fun _ -> +Target.create "Build" (fun _ -> Trace.trace " --- Building the app --- " ) -Target.create "Deploy" (fun _ -> +Target.create "Deploy" (fun _ -> Trace.trace " --- Deploying app --- " ) @@ -58,7 +58,7 @@ Now we have the following options: ## Final targets -Final targets can be used for TearDown functionality. +Final targets can be used for TearDown functionality. These targets will be executed even if the build fails but have to be activated via Target.ActivateFinal(). ```fsharp @@ -96,7 +96,7 @@ still be exectued in order. ### Setting the number of threads The number of threads used can be set using the environment variable ``parallel-jobs``. -This can be achieved in various ways where the easiest one is to use FAKE's built-in support for +This can be achieved in various ways where the easiest one is to use FAKE's built-in support for setting environment variables: ``fake *YourBuildScript* -e parallel-jobs 8`` @@ -140,7 +140,7 @@ For example this dependency tree: ![](pics/parallel/ParallelExample.png) -This is in addition to that that MsBuild may use multiple threads when building one solution having multiple independent project-files. +This is in addition to that that MSBuild may use multiple threads when building one solution having multiple independent project-files. # Soft dependencies @@ -148,7 +148,7 @@ Typically you will define dependencies among your targets using the `==>` and `< dependencies define the order in which the targets are executed during a build. You can also define soft dependencies among targets using the `?=>` and `<=?` operators. For example, you might -say that target B has a soft dependency on target A: +say that target B has a soft dependency on target A: ```fsharp "A" ?=> "B" @@ -156,18 +156,18 @@ say that target B has a soft dependency on target A: "B" <=? "A" ``` -With this soft dependency, running B will not require that A be run first. However it does mean that *if* A is run +With this soft dependency, running B will not require that A be run first. However it does mean that *if* A is run (due to other dependencies) it must be run before B. ## Example ```fsharp // *** Define Targets *** -Target.create "Clean" (fun _ -> +Target.create "Clean" (fun _ -> Trace.trace " --- Cleaning stuff --- " ) -Target.create "Build" (fun _ -> +Target.create "Build" (fun _ -> Trace.trace " --- Building the app --- " ) diff --git a/help/markdown/dotnet-assemblyinfo.md b/help/markdown/dotnet-assemblyinfo.md index 2e38cb7ee6a..7fa4c6d357f 100644 --- a/help/markdown/dotnet-assemblyinfo.md +++ b/help/markdown/dotnet-assemblyinfo.md @@ -9,7 +9,7 @@ If you succeeded with the [Getting Started tutorial](gettingstarted.html), then ```fsharp #r "paket: nuget Fake.DotNet.AssemblyInfo -nuget Fake.DotNet.MsBuild +nuget Fake.DotNet.MSBuild nuget Fake.Core.Target //" open Fake.DotNet @@ -30,7 +30,7 @@ Target.Create "BuildApp" (fun _ -> AssemblyInfo.Version version AssemblyInfo.FileVersion version] - MsBuild.RunRelease buildDir "Build" appReferences + MSBuild.RunRelease buildDir "Build" appReferences |> Log "AppBuild-Output: " ) ``` @@ -73,7 +73,7 @@ One of the easiest ways to retrieve this hash is to load use a reflector program ## Using the SolutionInfo approach -Some companies split their AssemblyInfo into a SolutionInfo.cs which is shared by all projects and a specific AssemblyInfo per project which contains the product data. +Some companies split their AssemblyInfo into a SolutionInfo.cs which is shared by all projects and a specific AssemblyInfo per project which contains the product data. All versioning data is generated by the AssemblyInfo task into the SolutionInfo.cs and the AssemblyInfo files are edited manually. This could look like this: ![alt text](pics/assemblyinfo/solutioninfo.png "SolutionInfo.cs is shared between projects") diff --git a/help/markdown/fake-gettingstarted.md b/help/markdown/fake-gettingstarted.md index 395919f212d..7f42168c165 100644 --- a/help/markdown/fake-gettingstarted.md +++ b/help/markdown/fake-gettingstarted.md @@ -159,15 +159,15 @@ In the dependencies section we say that the *Default* target has a dependency on In the next step we want to compile our C# libraries, which means we want to compile all csproj-files under */src/app* with MSBuild. -Again we need some new module for this, namely `Fake.DotNet.MsBuild`. +Again we need some new module for this, namely `Fake.DotNet.MSBuild`. -Just like before add the required module on top via `nuget Fake.DotNet.MsBuild`, delete the `build.fsx.lock` file and run the script. +Just like before add the required module on top via `nuget Fake.DotNet.MSBuild`, delete the `build.fsx.lock` file and run the script. Now edit the script like this: ```fsharp #r "paket: nuget Fake.IO.FileSystem -nuget Fake.DotNet.MsBuild +nuget Fake.DotNet.MSBuild nuget Fake.Core.Target //" #load "./.fake/build.fsx/intellisense.fsx" @@ -186,7 +186,7 @@ Target.create "Clean" (fun _ -> Target.create "BuildApp" (fun _ -> !! "src/app/**/*.csproj" - |> MsBuild.runRelease buildDir "Build" + |> MSBuild.runRelease buildDir "Build" |> Trace.Log "AppBuild-Output: " ) @@ -221,7 +221,7 @@ Now our main application will be built automatically and it's time to build the ```fsharp #r "paket: nuget Fake.IO.FileSystem -nuget Fake.DotNet.MsBuild +nuget Fake.DotNet.MSBuild nuget Fake.Core.Target //" #load "./.fake/build.fsx/intellisense.fsx" @@ -243,13 +243,13 @@ Target.create "Clean" (fun _ -> Target.create "BuildApp" (fun _ -> !! "src/app/**/*.csproj" - |> MsBuild.runRelease buildDir "Build" + |> MSBuild.runRelease buildDir "Build" |> Trace.logItems "AppBuild-Output: " ) Target.create "BuildTest" (fun _ -> !! "src/test/**/*.csproj" - |> MsBuild.runDebug testDir "Build" + |> MSBuild.runDebug testDir "Build" |> Trace.logItems "TestBuild-Output: " ) @@ -276,7 +276,7 @@ Now all our projects will be compiled and we can use FAKE's NUnit task in order ```fsharp #r "paket: nuget Fake.IO.FileSystem -nuget Fake.DotNet.MsBuild +nuget Fake.DotNet.MSBuild nuget Fake.DotNet.Testing.NUnit nuget Fake.Core.Target //" #load "./.fake/myscript.fsx/intellisense.fsx" @@ -298,13 +298,13 @@ Target.create "Clean" (fun _ -> Target.create "BuildApp" (fun _ -> !! "src/app/**/*.csproj" - |> MsBuild.runRelease buildDir "Build" + |> MSBuild.runRelease buildDir "Build" |> Trace.logItems "AppBuild-Output: " ) Target.create "BuildTest" (fun _ -> !! "src/test/**/*.csproj" - |> MsBuild.runDebug testDir "Build" + |> MSBuild.runDebug testDir "Build" |> Trace.logItems "TestBuild-Output: " ) diff --git a/help/markdown/legacy-core-targets.md b/help/markdown/legacy-core-targets.md index cda0352bad1..e641adcc757 100644 --- a/help/markdown/legacy-core-targets.md +++ b/help/markdown/legacy-core-targets.md @@ -17,18 +17,18 @@ FAKE has a special param "target" which can be used to run specific targets in a // include Fake libs #I @"tools\FAKE" #r "FakeLib.dll" - open Fake + open Fake // *** Define Targets *** - Target "Clean" (fun () -> + Target "Clean" (fun () -> trace " --- Cleaning stuff --- " ) - Target "Build" (fun () -> + Target "Build" (fun () -> trace " --- Building the app --- " ) - Target "Deploy" (fun () -> + Target "Deploy" (fun () -> trace " --- Deploying app --- " ) @@ -50,7 +50,7 @@ Now we have the following options: ## Final targets -Final targets can be used for TearDown functionality. +Final targets can be used for TearDown functionality. These targets will be executed even if the build fails but have to be activated via ActivateFinalTarget(). FinalTarget "CloseSomePrograms" (fun _ -> @@ -83,7 +83,7 @@ the build script contains a call like this: ``` RunTargetOrDefault "Default" -``` +``` ### Example @@ -118,7 +118,7 @@ still be exectued in order. ## Setting the number of threads The number of threads used can be set using the environment variable ``parallel-jobs``. -This can be achieved in various ways where the easiest one is to use FAKE's built-in support for +This can be achieved in various ways where the easiest one is to use FAKE's built-in support for setting environment variables: ``FAKE.exe *YourBuildScript* "parallel-jobs=8"`` @@ -137,7 +137,7 @@ However when a fast build is desired (and the project is e.g. known to build suc When using this parallel option, Fake resolves the build dependency hierearchies from the described paths and builds independend paths as parallel if you have multiple CPUs available. For example this dependency tree: - + "Task 1" ==> "Task A2" ==> "Task 3" @@ -158,14 +158,14 @@ For example this dependency tree: ![](pics/parallel/ParallelExample.png) -This is in addition to that that MsBuild may use multiple threads when building one solution having multiple independent project-files. +This is in addition to that that MSBuild may use multiple threads when building one solution having multiple independent project-files. # Writing custom C# tasks for FAKE **Note: This documentation is for FAKE.exe before version 5 (or the non-netcore version). The documentation needs te be updated, please help! ** -"FAKE - F# Make" is intended to be an extensible build framework and therefor it should be as easy as possible to create custom tasks. +"FAKE - F# Make" is intended to be an extensible build framework and therefor it should be as easy as possible to create custom tasks. This tutorial shows how to create a (very simple) custom task in C#. ## Creating a custom task @@ -198,7 +198,7 @@ Compile the project and put the generated assembly into the *tools/FAKE* path of // include CustomTask #r "MyCustomTask.dll" - open Fake + open Fake // open CustomNamespace open MyCustomTask @@ -212,27 +212,27 @@ If you want to use FAKE's standard functionality (like [globbing](http://en.wiki # Soft dependencies -Typically you will define dependencies among your targets using the `==>` and `<==` operators, and these +Typically you will define dependencies among your targets using the `==>` and `<==` operators, and these dependencies define the order in which the targets are executed during a build. You can also define soft dependencies among targets using the `?=>` and `<=?` operators. For example, you might -say that target B has a soft dependency on target A: - +say that target B has a soft dependency on target A: + "A" ?=> "B" // Or equivalently "B" <=? "A" -With this soft dependency, running B will not require that A be run first. However it does mean that *if* A is run +With this soft dependency, running B will not require that A be run first. However it does mean that *if* A is run (due to other dependencies) it must be run before B. ## Example // *** Define Targets *** - Target "Clean" (fun () -> + Target "Clean" (fun () -> trace " --- Cleaning stuff --- " ) - Target "Build" (fun () -> + Target "Build" (fun () -> trace " --- Building the app --- " ) diff --git a/help/templates/template.cshtml b/help/templates/template.cshtml index ecadabd4ce0..61c5f0263f3 100644 --- a/help/templates/template.cshtml +++ b/help/templates/template.cshtml @@ -104,7 +104,7 @@ -