Skip to content

Commit

Permalink
delete build.fsx and replace it with a fake build project
Browse files Browse the repository at this point in the history
  • Loading branch information
JKronberger committed May 11, 2023
1 parent cce1f85 commit dd6ea57
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 145 deletions.
124 changes: 124 additions & 0 deletions Weingartner.Json.Migration.Build/Program.fs
Original file line number Diff line number Diff line change
@@ -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
//-----------------------------------------------------------------------------
[<EntryPoint>]
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Fake.Core.Target" Version="6.0.0" />
<PackageReference Include="Fake.Tools.Git" Version="6.0.0" />
<PackageReference Include="Fake.Tools.GitVersion" Version="6.0.0" />
<PackageReference Include="MSBuild.StructuredLogger" Version="2.1.820" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="MSBuild.StructuredLogger" Version="2.1.820" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="xunit" Version="2.4.2" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="MSBuild.StructuredLogger">
<Version>2.1.820</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.3</Version>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MSBuild.StructuredLogger" Version="2.1.820" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3">
<GeneratePathProperty>True</GeneratePathProperty>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="MSBuild.StructuredLogger" Version="2.1.820" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="xunit" Version="2.4.2" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
Expand Down
16 changes: 11 additions & 5 deletions Weingartner.Json.Migration.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -52,11 +49,20 @@ 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
EndGlobalSection
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MSBuild.StructuredLogger" Version="2.1.820" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dotnet fake run .\scripts\build.fsx
dotnet run --project ./Weingartner.Json.Migration.Build/Weingartner.Json.Migration.Build.fsproj --verbosity q
132 changes: 0 additions & 132 deletions scripts/build.fsx

This file was deleted.

0 comments on commit dd6ea57

Please sign in to comment.