diff --git a/build.bat b/build.bat index 4cc9d1a..a3b9ef4 100644 --- a/build.bat +++ b/build.bat @@ -1,4 +1 @@ -REM If GitVersion is not available then run -REM cinst GitVersion.Portable -REM to install it -GitVersion.exe /output buildserver /exec scripts\lib\FAKE\tools\Fake.exe /execArgs "scripts\build.fsx %1 %2 %3 %4 %5 %6 %7 %8 %9 " /l console +dotnet fake run .\scripts\build.fsx diff --git a/scripts/build.fsx b/scripts/build.fsx index f81a379..294b81f 100644 --- a/scripts/build.fsx +++ b/scripts/build.fsx @@ -1,28 +1,44 @@ -#I @"lib" -#r @"Fake\tools\FakeLib.dll" - -open Fake -open Fake.MSBuildHelper -open Fake.Testing -open Fake.DotNetCli - -let nugetApiKey = getBuildParam "NuGetApiKey" -let outputPath = @".\artifacts" |> FullName -let buildOutputPath = @"bin\Release" - -Target "Clean" (fun _ -> - CleanDir outputPath -) - - -Target "BuildSolution" (fun () -> - - //RestoreMSSolutionPackages (fun p->p) "Weingartner.Json.Migration.sln" - - let slnPath = @".\Weingartner.Json.Migration.sln" - let setParams defaults = { +#r "paket: +nuget FSharp.Core 4.7.2 +nuget Fake.Core.Target +nuget Fake.IO.FileSystem +nuget Fake.DotNet.Cli +nuget Fake.DotNet.MSBuild +nuget Fake.DotNet.NuGet +nuget Fake.Tools.GitVersion //" +#load @".\.fake\build.fsx\intellisense.fsx" + +open System.IO +open Fake.Core +open Fake.Core.TargetOperators +open Fake.DotNet +open Fake.IO.Globbing.Operators +open Fake.IO.FileSystemOperators +open Fake.DotNet.NuGet + +Target.initEnvironment() + +// Properties +let baseDir = __SOURCE_DIRECTORY__ @@ ".." +let buildOutputPath = @".\bin\Release" +let artifactPath = baseDir @@ "artifacts" +let slnPath = @".\Weingartner.Json.Migration.sln" +let nugetVersion = if BuildServer.isLocalBuild + then ( + let gitVersion = Fake.Tools.GitVersion.generateProperties (fun paras -> { + paras with + ToolPath = Environment.environVarOrFail "ChocolateyInstall" @@ @"lib\GitVersion.Portable\tools\gitversion.exe" + }) + gitVersion.SemVer + ) + else BuildServer.buildVersion + +let msbuild target = ( + let setParams (defaults:MSBuildParams) = { defaults with - Targets = [ "Rebuild" ] + Verbosity = Some(MSBuildVerbosity.Minimal) + ToolsVersion = (Some "Current") + Targets = [ target ] Properties = [ "Optimize", "True" @@ -33,78 +49,91 @@ Target "BuildSolution" (fun () -> "DebugSymbols", "True" "OutputPath", buildOutputPath ] - Verbosity = Some(MSBuildVerbosity.Normal) NodeReuse = false } - build setParams slnPath + MSBuild.build setParams slnPath ) -Target "RunTests" (fun () -> - - let projects = !! @"**\*.Spec.csproj" - for project in projects do - let setParams (p: TestParams) = { p with Project = project } - (DotNetCli.Test setParams) +// Targets +Target.create "Clean" (fun _ -> + Trace.trace "########################################### clean outputdir ###########################################" + Fake.IO.Shell.cleanDir buildOutputPath + Fake.IO.Shell.cleanDir artifactPath ) -let nugetVersion = if buildVersion = "LocalBuild" then ( environVarOrFail "GitVersion_SemVer" ) else buildVersion +Target.create "BuildSolution" (fun _ -> + Trace.trace "########################################### msbuild restore ###########################################" + msbuild "restore" + Trace.trace "########################################### msbuild rebuild ###########################################" + msbuild "rebuild" +) -Target "NugetMigration" (fun()-> +let dotnet cmd workingDir = + let result = DotNet.exec (DotNet.Options.withWorkingDirectory workingDir) cmd "" + if result.ExitCode <> 0 then failwithf "'dotnet %s' failed in %s" cmd workingDir - let buildDir = "Weingartner.Json.Migration" @@ buildOutputPath +Target.create "RunTests" (fun _ -> + Trace.trace "########################################### run tests ###########################################" + !! @"**\*.Spec.csproj" + |> Seq.map Fake.IO.Path.getDirectory + |> Seq.iter (fun dir -> dotnet "test" dir) +) - NuGet (fun p -> - {p with - Authors = ["Weingartner Maschinenbau GmbH"] - Project = "Weingartner.Json.Migration" - Description = "Assists in migrating serialized JSON.Net objects" - OutputPath = "./artifacts" - Dependencies = - [ "Newtonsoft.Json", "12.0.3"] - Files = [ ("Weingartner*.dll", Some "lib/netstandard2.0", None )] - Summary = "Assists in migrating serialized JSON.Net objects" - Version = nugetVersion - WorkingDir = buildDir - AccessKey = nugetApiKey - Publish = false }) +Target.create "PackNugetMigration" (fun _ -> + + let workingDir = @".\Weingartner.Json.Migration" @@ buildOutputPath + NuGet.NuGetPack (fun p -> { + p with + Authors = ["Weingartner Maschinenbau GmbH"] + Project = "Weingartner.Json.Migration" + Description = "Assists in migrating serialized JSON.Net objects" + OutputPath = artifactPath + Dependencies = [ "Newtonsoft.Json", "12.0.3" ] + Files = [ ("Weingartner*.dll", Some("lib/netstandard2.0"), None )] + Summary = "Assists in migrating serialized JSON.Net objects" + Version = nugetVersion + WorkingDir = workingDir + Publish = false + }) "./base.nuspec" ) -Target "NugetAnalyzer" (fun()-> +Target.create "PackNugetAnalyzer" (fun _ -> - let buildDir = "Weingartner.Json.Migration.Roslyn" @@ buildOutputPath + let workingDir = @".\Weingartner.Json.Migration.Roslyn" @@ buildOutputPath - NuGet (fun p -> + NuGet.NuGetPack (fun p -> {p with Authors = ["Weingartner Maschinenbau GMBH"] Project = "Weingartner.Json.Migration.Analyzer" Description = "Assists in migrating serialized JSON.Net objects" - OutputPath = "./artifacts" + OutputPath = artifactPath Dependencies = [ "Weingartner.Json.Migration", nugetVersion "Newtonsoft.Json", "12.0.3" ] Summary = "Assists in migrating serialized JSON.Net objects" Version = nugetVersion - AccessKey = nugetApiKey - WorkingDir = buildDir + WorkingDir = workingDir Files = [ ( "Weingartner.Json.Migration.Roslyn.dll", Some "analyzers/dotnet/cs", Some "**/Microsoft.*;**/System.*") ( "tools/**/*.*", None, None) ] - Publish = false }) + Publish = false + }) "./base.nuspec" ) -Target "NugetPack" DoNothing -Target "Default" DoNothing - -"NugetMigration" <== [ "BuildSolution" ] -"NugetAnalyzer" <== [ "BuildSolution" ] -"NugetPack" <== [ "NugetMigration"; "NugetAnalyzer" ] -"NugetPack" <== [ "BuildSolution" ] -"RunTests" <== [ "BuildSolution" ] +Target.create "Default" (fun _ -> + Trace.trace "Finished" +) -"Default" <== [ "Clean"; "NugetPack"; "RunTests" ] +// Dependencies +"Clean" + ==> "BuildSolution" + ==> "RunTests" + ==> "PackNugetMigration" + ==> "PackNugetAnalyzer" + ==> "Default" -RunTargetOrDefault "Default" +Target.runOrDefault "Default" \ No newline at end of file diff --git a/scripts/build.fsx.lock b/scripts/build.fsx.lock new file mode 100644 index 0000000..2afe1ed --- /dev/null +++ b/scripts/build.fsx.lock @@ -0,0 +1,235 @@ +STORAGE: NONE +RESTRICTION: == netstandard2.0 +NUGET + remote: https://api.nuget.org/v3/index.json + BlackFox.VsWhere (1.1) + FSharp.Core (>= 4.2.3) + Microsoft.Win32.Registry (>= 4.7) + Fake.Core.CommandLineParsing (5.20.3) + FParsec (>= 1.1.1) + FSharp.Core (>= 4.7.2) + Fake.Core.Context (5.20.3) + FSharp.Core (>= 4.7.2) + Fake.Core.Environment (5.20.3) + FSharp.Core (>= 4.7.2) + Fake.Core.FakeVar (5.20.3) + Fake.Core.Context (>= 5.20.3) + FSharp.Core (>= 4.7.2) + Fake.Core.Process (5.20.3) + Fake.Core.Environment (>= 5.20.3) + Fake.Core.FakeVar (>= 5.20.3) + Fake.Core.String (>= 5.20.3) + Fake.Core.Trace (>= 5.20.3) + Fake.IO.FileSystem (>= 5.20.3) + FSharp.Core (>= 4.7.2) + System.Collections.Immutable (>= 1.7.1) + Fake.Core.SemVer (5.20.3) + FSharp.Core (>= 4.7.2) + Fake.Core.String (5.20.3) + FSharp.Core (>= 4.7.2) + Fake.Core.Target (5.20.3) + Fake.Core.CommandLineParsing (>= 5.20.3) + Fake.Core.Context (>= 5.20.3) + Fake.Core.Environment (>= 5.20.3) + Fake.Core.FakeVar (>= 5.20.3) + Fake.Core.Process (>= 5.20.3) + Fake.Core.String (>= 5.20.3) + Fake.Core.Trace (>= 5.20.3) + FSharp.Control.Reactive (>= 4.4.2) + FSharp.Core (>= 4.7.2) + Fake.Core.Tasks (5.20.3) + Fake.Core.Trace (>= 5.20.3) + FSharp.Core (>= 4.7.2) + Fake.Core.Trace (5.20.3) + Fake.Core.Environment (>= 5.20.3) + Fake.Core.FakeVar (>= 5.20.3) + FSharp.Core (>= 4.7.2) + Fake.Core.Xml (5.20.3) + Fake.Core.String (>= 5.20.3) + FSharp.Core (>= 4.7.2) + Fake.DotNet.Cli (5.20.3) + Fake.Core.Environment (>= 5.20.3) + Fake.Core.Process (>= 5.20.3) + Fake.Core.String (>= 5.20.3) + Fake.Core.Trace (>= 5.20.3) + Fake.DotNet.MSBuild (>= 5.20.3) + Fake.DotNet.NuGet (>= 5.20.3) + Fake.IO.FileSystem (>= 5.20.3) + FSharp.Core (>= 4.7.2) + Mono.Posix.NETStandard (>= 1.0) + Newtonsoft.Json (>= 12.0.3) + Fake.DotNet.MSBuild (5.20.3) + BlackFox.VsWhere (>= 1.1) + Fake.Core.Environment (>= 5.20.3) + Fake.Core.Process (>= 5.20.3) + Fake.Core.String (>= 5.20.3) + Fake.Core.Trace (>= 5.20.3) + Fake.IO.FileSystem (>= 5.20.3) + FSharp.Core (>= 4.7.2) + MSBuild.StructuredLogger (>= 2.1.176) + Fake.DotNet.NuGet (5.20.3) + Fake.Core.Environment (>= 5.20.3) + Fake.Core.Process (>= 5.20.3) + Fake.Core.SemVer (>= 5.20.3) + Fake.Core.String (>= 5.20.3) + Fake.Core.Tasks (>= 5.20.3) + Fake.Core.Trace (>= 5.20.3) + Fake.Core.Xml (>= 5.20.3) + Fake.IO.FileSystem (>= 5.20.3) + Fake.Net.Http (>= 5.20.3) + FSharp.Core (>= 4.7.2) + Newtonsoft.Json (>= 12.0.3) + NuGet.Protocol (>= 5.6) + Fake.IO.FileSystem (5.20.3) + Fake.Core.String (>= 5.20.3) + FSharp.Core (>= 4.7.2) + Fake.Net.Http (5.20.3) + Fake.Core.Trace (>= 5.20.3) + FSharp.Core (>= 4.7.2) + Fake.Tools.GitVersion (5.20.3) + Fake.Core.Environment (>= 5.20.3) + Fake.Core.Process (>= 5.20.3) + Fake.IO.FileSystem (>= 5.20.3) + FSharp.Core (>= 4.7.2) + Newtonsoft.Json (>= 12.0.3) + FParsec (1.1.1) + FSharp.Core (>= 4.3.4) + FSharp.Control.Reactive (4.5) + FSharp.Core (>= 4.7.2) + System.Reactive (>= 4.4.1) + FSharp.Core (4.7.2) + Microsoft.Build (16.8) + Microsoft.Build.Framework (16.8) + System.Security.Permissions (>= 4.7) + Microsoft.Build.Tasks.Core (16.8) + Microsoft.Build.Framework (>= 16.8) + Microsoft.Build.Utilities.Core (>= 16.8) + Microsoft.Win32.Registry (>= 4.3) + System.CodeDom (>= 4.4) + System.Collections.Immutable (>= 1.5) + System.Reflection.Metadata (>= 1.6) + System.Reflection.TypeExtensions (>= 4.1) + System.Resources.Extensions (>= 4.6) + System.Runtime.InteropServices (>= 4.3) + System.Security.Cryptography.Pkcs (>= 4.7) + System.Security.Cryptography.Xml (>= 4.7) + System.Security.Permissions (>= 4.7) + System.Threading.Tasks.Dataflow (>= 4.9) + Microsoft.Build.Utilities.Core (16.8) + Microsoft.Build.Framework (>= 16.8) + Microsoft.Win32.Registry (>= 4.3) + System.Collections.Immutable (>= 1.5) + System.Security.Permissions (>= 4.7) + System.Text.Encoding.CodePages (>= 4.0.1) + Microsoft.NETCore.Platforms (5.0) + Microsoft.NETCore.Targets (5.0) + Microsoft.Win32.Registry (5.0) + System.Buffers (>= 4.5.1) + System.Memory (>= 4.5.4) + System.Security.AccessControl (>= 5.0) + System.Security.Principal.Windows (>= 5.0) + Mono.Posix.NETStandard (1.0) + MSBuild.StructuredLogger (2.1.303) + Microsoft.Build (>= 16.4) + Microsoft.Build.Framework (>= 16.4) + Microsoft.Build.Tasks.Core (>= 16.4) + Microsoft.Build.Utilities.Core (>= 16.4) + Newtonsoft.Json (12.0.3) + NuGet.Common (5.8.1) + NuGet.Frameworks (>= 5.8.1) + NuGet.Configuration (5.8.1) + NuGet.Common (>= 5.8.1) + System.Security.Cryptography.ProtectedData (>= 4.4) + NuGet.Frameworks (5.8.1) + NuGet.Packaging (5.8.1) + Newtonsoft.Json (>= 9.0.1) + NuGet.Configuration (>= 5.8.1) + NuGet.Versioning (>= 5.8.1) + System.Security.Cryptography.Cng (>= 5.0) + System.Security.Cryptography.Pkcs (>= 5.0) + NuGet.Protocol (5.8.1) + NuGet.Packaging (>= 5.8.1) + NuGet.Versioning (5.8.1) + System.Buffers (4.5.1) + System.CodeDom (5.0) + System.Collections.Immutable (5.0) + System.Memory (>= 4.5.4) + System.Formats.Asn1 (5.0) + System.Buffers (>= 4.5.1) + System.Memory (>= 4.5.4) + System.IO (4.3) + Microsoft.NETCore.Platforms (>= 1.1) + Microsoft.NETCore.Targets (>= 1.1) + System.Runtime (>= 4.3) + System.Text.Encoding (>= 4.3) + System.Threading.Tasks (>= 4.3) + System.Memory (4.5.4) + System.Buffers (>= 4.5.1) + System.Numerics.Vectors (>= 4.4) + System.Runtime.CompilerServices.Unsafe (>= 4.5.3) + System.Numerics.Vectors (4.5) + System.Reactive (5.0) + System.Runtime.InteropServices.WindowsRuntime (>= 4.3) + System.Threading.Tasks.Extensions (>= 4.5.4) + System.Reflection (4.3) + Microsoft.NETCore.Platforms (>= 1.1) + Microsoft.NETCore.Targets (>= 1.1) + System.IO (>= 4.3) + System.Reflection.Primitives (>= 4.3) + System.Runtime (>= 4.3) + System.Reflection.Metadata (5.0) + System.Collections.Immutable (>= 5.0) + System.Reflection.Primitives (4.3) + Microsoft.NETCore.Platforms (>= 1.1) + Microsoft.NETCore.Targets (>= 1.1) + System.Runtime (>= 4.3) + System.Reflection.TypeExtensions (4.7) + System.Resources.Extensions (5.0) + System.Memory (>= 4.5.4) + System.Runtime (4.3.1) + Microsoft.NETCore.Platforms (>= 1.1.1) + Microsoft.NETCore.Targets (>= 1.1.3) + System.Runtime.CompilerServices.Unsafe (5.0) + System.Runtime.Handles (4.3) + Microsoft.NETCore.Platforms (>= 1.1) + Microsoft.NETCore.Targets (>= 1.1) + System.Runtime (>= 4.3) + System.Runtime.InteropServices (4.3) + Microsoft.NETCore.Platforms (>= 1.1) + Microsoft.NETCore.Targets (>= 1.1) + System.Reflection (>= 4.3) + System.Reflection.Primitives (>= 4.3) + System.Runtime (>= 4.3) + System.Runtime.Handles (>= 4.3) + System.Runtime.InteropServices.WindowsRuntime (4.3) + System.Runtime (>= 4.3) + System.Security.AccessControl (5.0) + System.Security.Principal.Windows (>= 5.0) + System.Security.Cryptography.Cng (5.0) + System.Security.Cryptography.Pkcs (5.0.1) + System.Buffers (>= 4.5.1) + System.Formats.Asn1 (>= 5.0) + System.Memory (>= 4.5.4) + System.Security.Cryptography.Cng (>= 5.0) + System.Security.Cryptography.ProtectedData (5.0) + System.Memory (>= 4.5.4) + System.Security.Cryptography.Xml (5.0) + System.Memory (>= 4.5.4) + System.Security.Cryptography.Pkcs (>= 5.0) + System.Security.Permissions (>= 5.0) + System.Security.Permissions (5.0) + System.Security.AccessControl (>= 5.0) + System.Security.Principal.Windows (5.0) + System.Text.Encoding (4.3) + Microsoft.NETCore.Platforms (>= 1.1) + Microsoft.NETCore.Targets (>= 1.1) + System.Runtime (>= 4.3) + System.Text.Encoding.CodePages (5.0) + System.Runtime.CompilerServices.Unsafe (>= 5.0) + System.Threading.Tasks (4.3) + Microsoft.NETCore.Platforms (>= 1.1) + Microsoft.NETCore.Targets (>= 1.1) + System.Runtime (>= 4.3) + System.Threading.Tasks.Dataflow (5.0) + System.Threading.Tasks.Extensions (4.5.4) + System.Runtime.CompilerServices.Unsafe (>= 4.5.3)