Skip to content

Commit

Permalink
Merge pull request #43 from zvirja/improve-build-script
Browse files Browse the repository at this point in the history
Rework build script to rely on `dotnet` only
  • Loading branch information
moodmosaic committed Jul 27, 2018
2 parents 71eaf12 + 5c859b1 commit bd9c845
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 56 deletions.
77 changes: 22 additions & 55 deletions Build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,59 +79,36 @@ let buildVersion = match getBuildParamOrDefault "BuildVersion" "git" with
infoVersion = getBuildParamOrDefault "BuildInfoVersion" assemblyVer
nugetVersion = getBuildParamOrDefault "BuildNugetVersion" assemblyVer
source = None }

let runMsBuild target configuration properties =
let verbosity = match getBuildParam "BuildVerbosity" |> toLower with
| "quiet" | "q" -> Quiet
| "minimal" | "m" -> Minimal
| "normal" | "n" -> Normal
| "detailed" | "d" -> Detailed
| "diagnostic" | "diag" -> Diagnostic
| _ -> Minimal

let configProperty = match configuration with
| Some c -> [ "Configuration", c ]
| _ -> []

let properties = configProperty @ properties
@ [ "AssemblyVersion", buildVersion.assemblyVersion
"FileVersion", buildVersion.fileVersion
"InformationalVersion", buildVersion.infoVersion
"PackageVersion", buildVersion.nugetVersion ]

solutionToBuild
|> build (fun p -> { p with MaxCpuCount = Some None
Verbosity = Some verbosity
Targets = [ target ]
Properties = properties })

let rebuild configuration = runMsBuild "Rebuild" (Some configuration) []

Target "RestoreNuGetPackages" (fun _ -> runMsBuild "Restore" None [])

Target "VerifyOnly" (fun _ -> rebuild "Verify")

Target "BuildOnly" (fun _ -> rebuild configuration)
Target "TestOnly" (fun _ ->

let runDotNet command configuration properties =
let stringProps = properties
@ [ "AssemblyVersion", buildVersion.assemblyVersion
"FileVersion", buildVersion.fileVersion
"InformationalVersion", buildVersion.infoVersion
"PackageVersion", buildVersion.nugetVersion ]
|> Seq.map(fun (name, value) -> sprintf "/p:%s=%s" name value )
|> String.concat " "

DotNetCli.RunCommand id
(sprintf "%s %s --configuration %s %s" command solutionToBuild configuration stringProps)

Target "Verify" (fun _ -> runDotNet "build" configuration [])
Target "Build" (fun _ -> runDotNet "build" configuration [])

Target "Test" (fun _ ->
DotNetCli.RunCommand (fun p -> { p with WorkingDir = testProjectDir })
(sprintf "xunit --configuration %s --no-build -x86" configuration)
(sprintf "test --configuration %s" configuration)
)

Target "Verify" DoNothing
Target "Build" DoNothing
Target "Test" DoNothing

Target "CleanNuGetPackages" (fun _ ->
CleanDir nuGetOutputFolder
)

Target "NuGetPack" (fun _ ->
// Pack projects using MSBuild.
runMsBuild "Pack" (Some configuration) [ "IncludeSource", "true"
"IncludeSymbols", "true"
"PackageOutputPath", FullName nuGetOutputFolder
"NoBuild", "true" ]

runDotNet "pack" configuration [ "IncludeSource", "true"
"IncludeSymbols", "true"
"PackageOutputPath", FullName nuGetOutputFolder ]
)

let publishPackagesWithSymbols packageFeed symbolFeed accessKey =
Expand Down Expand Up @@ -159,18 +136,8 @@ Target "PublishNuGetPublic" (fun _ ->

Target "CompleteBuild" DoNothing

"RestoreNuGetPackages" ==> "Verify"
"VerifyOnly" ==> "Verify"

"Verify" ==> "Build"
"BuildOnly" ==> "Build"

"BuildOnly" ==> "TestOnly"

"Build" ==> "Test"
"TestOnly" ==> "Test"

"CleanNuGetPackages" ==> "NuGetPack"
"Verify" ==> "NuGetPack"
"Test" ==> "NuGetPack"

"NuGetPack" ==> "CompleteBuild"
Expand Down
1 change: 0 additions & 1 deletion Src/Fare.IntegrationTests/Fare.IntegrationTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

<PackageReference Include="xunit" Version="2.3.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0" />

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
</ItemGroup>
Expand Down
7 changes: 7 additions & 0 deletions Src/Fare.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fare", "Fare\Fare.csproj",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fare.IntegrationTests", "Fare.IntegrationTests\Fare.IntegrationTests.csproj", "{20F5CC3B-9D71-472A-BD28-3A4C104A00E4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{84A69DF5-281E-45DC-817F-663008351957}"
ProjectSection(SolutionItems) = preProject
..\.editorconfig = ..\.editorconfig
..\appveyor.yml = ..\appveyor.yml
..\Build.fsx = ..\Build.fsx
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down

0 comments on commit bd9c845

Please sign in to comment.