From dd6ea570acde74e13f014bc62f96b1f4b52efb26 Mon Sep 17 00:00:00 2001 From: JKronberger Date: Thu, 11 May 2023 09:48:07 +0200 Subject: [PATCH] delete build.fsx and replace it with a fake build project --- Weingartner.Json.Migration.Build/Program.fs | 124 ++++++++++++++++ .../Weingartner.Json.Migration.Build.fsproj | 19 +++ ...ngartner.Json.Migration.Roslyn.Spec.csproj | 1 - ...ner.Json.Migration.Roslyn_Vsix.Vsix.csproj | 3 - .../Weingartner.Json.Migration.Roslyn.csproj | 1 - .../Weingartner.Json.Migration.Spec.csproj | 1 - Weingartner.Json.Migration.sln | 16 ++- .../Weingartner.Json.Migration.csproj | 1 - build.bat | 2 +- scripts/build.fsx | 132 ------------------ 10 files changed, 155 insertions(+), 145 deletions(-) create mode 100644 Weingartner.Json.Migration.Build/Program.fs create mode 100644 Weingartner.Json.Migration.Build/Weingartner.Json.Migration.Build.fsproj delete mode 100644 scripts/build.fsx diff --git a/Weingartner.Json.Migration.Build/Program.fs b/Weingartner.Json.Migration.Build/Program.fs new file mode 100644 index 0000000..f25971d --- /dev/null +++ b/Weingartner.Json.Migration.Build/Program.fs @@ -0,0 +1,124 @@ +open System.IO +open Fake.Core +open Fake.Core.TargetOperators +open Fake.IO.Globbing.Operators +open Fake.IO.FileSystemOperators +open Fake.IO +open Fake.DotNet +open Fake.Tools + + +// Properties +let baseDir = (__SOURCE_DIRECTORY__ @@ "..") |> Path.GetFullPath +let buildOutputs = !! @"**\bin" +let artifactPath = baseDir @@ "artifacts" +let slnPath = baseDir @@ "Weingartner.Json.Migration.sln" +let migrationProject = baseDir @@ "Weingartner.Json.Migration" @@ "Weingartner.Json.Migration.csproj" +let analyzerProject = baseDir @@ "Weingartner.Json.Migration.Roslyn" @@ "Weingartner.Json.Migration.Roslyn.csproj" +let gitVersion = GitVersion.generateProperties(id) +let assemblySemVer = gitVersion.AssemblySemVer + +let initTargets () = + //----------------------------------------------------------------------------- + // Target Declaration + //----------------------------------------------------------------------------- + Target.create "Clean" (fun _ -> + Trace.trace "########################################### clean outputdir ###########################################" + buildOutputs |> Seq.iter Trace.trace + //Shell.cleanDirs buildOutputs + Shell.cleanDir artifactPath + Trace.log ("####################Build Version#######################: " + assemblySemVer) + ) + + // build + let dotnetBuild proj = + DotNet.build (fun defaults -> { + defaults with + Configuration = DotNet.BuildConfiguration.Release + MSBuildParams = { MSBuild.CliArguments.Create() with DisableInternalBinLog = true } + }) proj + + Target.create "BuildSolution" (fun _ -> + Trace.log " -------------- restore --------------" + !! @"**\*.csproj" + |> Seq.filter (fun p -> not (p.Contains(".Vsix.csproj"))) + |> Seq.iter (fun p -> dotnetBuild p) + ) + + // testing + let dotnetTest proj = + DotNet.test (fun defaults -> { + defaults with + Configuration = DotNet.BuildConfiguration.Release + MSBuildParams = { MSBuild.CliArguments.Create() with DisableInternalBinLog = true } + NoRestore = true + NoBuild = true + }) proj + + Target.create "RunTests" (fun _ -> + Trace.trace "########################################### run tests ###########################################" + !! @"**\*.Spec.csproj" + |> Seq.iter dotnetTest + ) + + // nuget packaging + let packMSBuildParams = { + MSBuild.CliArguments.Create() with + DisableInternalBinLog = true + ToolsVersion = (Some "Current") + Properties = + [ + "Configuration", "Release" + "Version", gitVersion.SemVer + ] + NodeReuse = false + } + + Target.create "PackNugetMigration" (fun _ -> + DotNet.pack (fun defaults -> { + defaults with + OutputPath = Some artifactPath + MSBuildParams = packMSBuildParams + NoRestore = true + NoBuild = true + }) + migrationProject + ) + + Target.create "PackNugetAnalyzer" (fun _ -> + DotNet.pack (fun defaults -> { + defaults with + OutputPath = Some artifactPath + MSBuildParams = packMSBuildParams + NoRestore = true + NoBuild = true + }) + analyzerProject + ) + + Target.create "Default" (fun _ -> + Trace.trace "Finished" + ) + + // Dependencies + "Clean" + ==> "BuildSolution" + ==> "RunTests" + ==> "PackNugetMigration" + ==> "PackNugetAnalyzer" + ==> "Default" + +//----------------------------------------------------------------------------- +// Target Start +//----------------------------------------------------------------------------- +[] +let main argv = + argv + |> Array.toList + |> Context.FakeExecutionContext.Create false "build.fsx" + |> Context.RuntimeContext.Fake + |> Context.setExecutionContext + initTargets () |> ignore + Target.runOrDefault "Default" + + 0 // return an integer exit code diff --git a/Weingartner.Json.Migration.Build/Weingartner.Json.Migration.Build.fsproj b/Weingartner.Json.Migration.Build/Weingartner.Json.Migration.Build.fsproj new file mode 100644 index 0000000..1b9a83b --- /dev/null +++ b/Weingartner.Json.Migration.Build/Weingartner.Json.Migration.Build.fsproj @@ -0,0 +1,19 @@ + + + + Exe + net6.0 + + + + + + + + + + + + + + diff --git a/Weingartner.Json.Migration.Roslyn.Spec/Weingartner.Json.Migration.Roslyn.Spec.csproj b/Weingartner.Json.Migration.Roslyn.Spec/Weingartner.Json.Migration.Roslyn.Spec.csproj index 5260002..ed2970c 100644 --- a/Weingartner.Json.Migration.Roslyn.Spec/Weingartner.Json.Migration.Roslyn.Spec.csproj +++ b/Weingartner.Json.Migration.Roslyn.Spec/Weingartner.Json.Migration.Roslyn.Spec.csproj @@ -10,7 +10,6 @@ - diff --git a/Weingartner.Json.Migration.Roslyn.Vsix/Weingartner.Json.Migration.Roslyn_Vsix.Vsix.csproj b/Weingartner.Json.Migration.Roslyn.Vsix/Weingartner.Json.Migration.Roslyn_Vsix.Vsix.csproj index 8fe7716..762bed0 100644 --- a/Weingartner.Json.Migration.Roslyn.Vsix/Weingartner.Json.Migration.Roslyn_Vsix.Vsix.csproj +++ b/Weingartner.Json.Migration.Roslyn.Vsix/Weingartner.Json.Migration.Roslyn_Vsix.Vsix.csproj @@ -94,9 +94,6 @@ - - 2.1.820 - 13.0.3 diff --git a/Weingartner.Json.Migration.Roslyn/Weingartner.Json.Migration.Roslyn.csproj b/Weingartner.Json.Migration.Roslyn/Weingartner.Json.Migration.Roslyn.csproj index dd41c61..6decea9 100644 --- a/Weingartner.Json.Migration.Roslyn/Weingartner.Json.Migration.Roslyn.csproj +++ b/Weingartner.Json.Migration.Roslyn/Weingartner.Json.Migration.Roslyn.csproj @@ -17,7 +17,6 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - True diff --git a/Weingartner.Json.Migration.Spec/Weingartner.Json.Migration.Spec.csproj b/Weingartner.Json.Migration.Spec/Weingartner.Json.Migration.Spec.csproj index d49167c..97a1046 100644 --- a/Weingartner.Json.Migration.Spec/Weingartner.Json.Migration.Spec.csproj +++ b/Weingartner.Json.Migration.Spec/Weingartner.Json.Migration.Spec.csproj @@ -11,7 +11,6 @@ - diff --git a/Weingartner.Json.Migration.sln b/Weingartner.Json.Migration.sln index dad7653..c1e18b5 100644 --- a/Weingartner.Json.Migration.sln +++ b/Weingartner.Json.Migration.sln @@ -21,12 +21,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Weingartner.Json.Migration. EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Weingartner.Migration.Common.Shared", "Weingartner.Migration.Common.Shared\Weingartner.Migration.Common.Shared.shproj", "{D1EBB04A-A30B-43A6-A1A7-945BCFDF8EF0}" EndProject +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Weingartner.Json.Migration.Build", "Weingartner.Json.Migration.Build\Weingartner.Json.Migration.Build.fsproj", "{61F7AF56-A9E2-4390-B674-C48D2186F0C3}" +EndProject Global - GlobalSection(SharedMSBuildProjectFiles) = preSolution - Weingartner.Migration.Common.Shared\Weingartner.Migration.Common.Shared.projitems*{567ecd20-eb97-4a30-a5b2-0889d1609491}*SharedItemsImports = 5 - Weingartner.Migration.Common.Shared\Weingartner.Migration.Common.Shared.projitems*{630bac68-a278-4bce-abf1-6c864b141aa0}*SharedItemsImports = 5 - Weingartner.Migration.Common.Shared\Weingartner.Migration.Common.Shared.projitems*{d1ebb04a-a30b-43a6-a1a7-945bcfdf8ef0}*SharedItemsImports = 13 - EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU @@ -52,6 +49,10 @@ Global {2E3DF5C2-8A38-4A03-86D7-8D463C917E47}.Debug|Any CPU.Build.0 = Debug|Any CPU {2E3DF5C2-8A38-4A03-86D7-8D463C917E47}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E3DF5C2-8A38-4A03-86D7-8D463C917E47}.Release|Any CPU.Build.0 = Release|Any CPU + {61F7AF56-A9E2-4390-B674-C48D2186F0C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {61F7AF56-A9E2-4390-B674-C48D2186F0C3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {61F7AF56-A9E2-4390-B674-C48D2186F0C3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {61F7AF56-A9E2-4390-B674-C48D2186F0C3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -59,4 +60,9 @@ Global GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {F17857EC-72DD-4007-8A57-3740BF6160FE} EndGlobalSection + GlobalSection(SharedMSBuildProjectFiles) = preSolution + Weingartner.Migration.Common.Shared\Weingartner.Migration.Common.Shared.projitems*{567ecd20-eb97-4a30-a5b2-0889d1609491}*SharedItemsImports = 5 + Weingartner.Migration.Common.Shared\Weingartner.Migration.Common.Shared.projitems*{630bac68-a278-4bce-abf1-6c864b141aa0}*SharedItemsImports = 5 + Weingartner.Migration.Common.Shared\Weingartner.Migration.Common.Shared.projitems*{d1ebb04a-a30b-43a6-a1a7-945bcfdf8ef0}*SharedItemsImports = 13 + EndGlobalSection EndGlobal diff --git a/Weingartner.Json.Migration/Weingartner.Json.Migration.csproj b/Weingartner.Json.Migration/Weingartner.Json.Migration.csproj index 28f37cf..623f6ac 100644 --- a/Weingartner.Json.Migration/Weingartner.Json.Migration.csproj +++ b/Weingartner.Json.Migration/Weingartner.Json.Migration.csproj @@ -11,7 +11,6 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/build.bat b/build.bat index a3b9ef4..5f11150 100644 --- a/build.bat +++ b/build.bat @@ -1 +1 @@ -dotnet fake run .\scripts\build.fsx +dotnet run --project ./Weingartner.Json.Migration.Build/Weingartner.Json.Migration.Build.fsproj --verbosity q diff --git a/scripts/build.fsx b/scripts/build.fsx deleted file mode 100644 index 6a93688..0000000 --- a/scripts/build.fsx +++ /dev/null @@ -1,132 +0,0 @@ -#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.DotNet.Testing.XUnit2 -nuget Fake.Testing.Common -nuget Fake.Tools.GitVersion -nuget xunit.runner.console //" -#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.Testing - -Target.initEnvironment() - -// Properties -let baseDir = (__SOURCE_DIRECTORY__ @@ "..") |> Path.GetFullPath -let buildOutputs = !! @"**\bin" -let artifactPath = baseDir @@ "artifacts" -let slnPath = baseDir @@ "Weingartner.Json.Migration.sln" -let migrationProject = baseDir @@ "Weingartner.Json.Migration" @@ "Weingartner.Json.Migration.csproj" -let analyzerProject = baseDir @@ "Weingartner.Json.Migration.Roslyn" @@ "Weingartner.Json.Migration.Roslyn.csproj" - -let gitVersion = Fake.Tools.GitVersion.generateProperties(id) - - -// Targets -Target.create "Clean" (fun _ -> - Trace.trace "########################################### clean outputdir ###########################################" - buildOutputs |> Seq.iter Trace.trace - Fake.IO.Shell.cleanDirs buildOutputs - Fake.IO.Shell.cleanDir artifactPath -) - -// build -let msbuild target = - let setParams (defaults:MSBuildParams) = { - defaults with - Verbosity = Some(MSBuildVerbosity.Minimal) - ToolsVersion = (Some "Current") - Targets = target - Properties = - [ - "Optimize", "True" - "Configuration", "Release" - "Platform", "Any CPU" - "BuildParallel", "True" - "BuildProjectReferences", "True" - "DebugSymbols", "True" - "Version", gitVersion.AssemblySemVer - ] - NodeReuse = false - } - MSBuild.build setParams slnPath - -Target.create "BuildSolution" (fun _ -> - Trace.trace "########################################### msbuild restore ###########################################" - Trace.trace "########################################### msbuild rebuild ###########################################" - msbuild [ "restore"; "rebuild" ] -) - -// testing -let dotnetTest proj = - DotNet.test (fun defaults -> { - defaults with - Configuration = DotNet.BuildConfiguration.Release - NoRestore = true - NoBuild = true - }) proj - -Target.create "RunTests" (fun _ -> - Trace.trace "########################################### run tests ###########################################" - !! @"**\*.Spec.csproj" - |> Seq.iter dotnetTest - -) - -// nuget packaging -let packMSBuildParams = { - MSBuild.CliArguments.Create() with - ToolsVersion = (Some "Current") - Properties = - [ - "Configuration", "Release" - "Version", gitVersion.SemVer - ] - NodeReuse = false -} - -Target.create "PackNugetMigration" (fun _ -> - DotNet.pack (fun defaults -> { - defaults with - OutputPath = Some artifactPath - MSBuildParams = packMSBuildParams - NoRestore = true - NoBuild = true - }) - migrationProject -) - -Target.create "PackNugetAnalyzer" (fun _ -> - DotNet.pack (fun defaults -> { - defaults with - OutputPath = Some artifactPath - MSBuildParams = packMSBuildParams - NoRestore = true - NoBuild = true - }) - analyzerProject -) - -Target.create "Default" (fun _ -> - Trace.trace "Finished" -) - -// Dependencies -"Clean" - ==> "BuildSolution" - ==> "RunTests" - ==> "PackNugetMigration" - ==> "PackNugetAnalyzer" - ==> "Default" - -Target.runOrDefault "Default" \ No newline at end of file