|
1 | 1 | #I @"packages/FAKE/tools" |
| 2 | +#I @"packages/FAKE.BuildLib/lib/net451" |
2 | 3 | #r "FakeLib.dll" |
| 4 | +#r "BuildLib.dll" |
3 | 5 |
|
4 | 6 | open Fake |
5 | 7 | open Fake.FileHelper |
| 8 | +open BuildLib |
6 | 9 | open System.IO |
7 | 10 |
|
8 | | -// ---------------------------------------------------------------------------- Variables |
| 11 | +let solution = |
| 12 | + initSolution |
| 13 | + "./Json.Net.Unity3D.sln" "Release" [] |
9 | 14 |
|
10 | | -let buildSolutionFile = "./Json.Net.Unity3D.sln" |
11 | | -let buildConfiguration = "Release" |
12 | | -let binDir = "bin" |
13 | | -let testDir = binDir @@ "test" |
| 15 | +Target "Clean" <| fun _ -> cleanBin |
14 | 16 |
|
15 | | -// ------------------------------------------------------------------------- Unity Helper |
| 17 | +Target "Restore" <| fun _ -> restoreNugetPackages solution |
16 | 18 |
|
17 | | -let UnityPath = |
18 | | - @"C:\Program Files\Unity\Editor\Unity.exe" |
19 | | - |
20 | | -let Unity projectPath args = |
21 | | - let result = Shell.Exec(UnityPath, "-quit -batchmode -logFile -projectPath \"" + projectPath + "\" " + args) |
22 | | - if result < 0 then failwithf "Unity exited with error %d" result |
23 | | - |
24 | | -// ------------------------------------------------------------------------------ Targets |
25 | | - |
26 | | -Target "Clean" (fun _ -> |
27 | | - CleanDirs [binDir] |
28 | | -) |
29 | | - |
30 | | -Target "Build" (fun _ -> |
| 19 | +Target "Build" <| fun _ -> |
31 | 20 | // Regular |
32 | | - !! buildSolutionFile |
33 | | - |> MSBuild "" "Rebuild" [ "Configuration", buildConfiguration ] |
34 | | - |> Log "Build-Output: " |
| 21 | + buildSolution solution |
35 | 22 | // Lite |
36 | | - !! buildSolutionFile |
37 | | - |> MSBuild "" "Rebuild" [ "Configuration", buildConfiguration + "Lite" ] |
38 | | - |> Log "Build-Output: " |
39 | | -) |
| 23 | + !!solution.SolutionFile |
| 24 | + |> MSBuild "" "Rebuild" [ "Configuration", solution.Configuration + "Lite" ] |
| 25 | + |> Log "Build-Output: " |
| 26 | + |
40 | 27 |
|
41 | | -Target "Test" (fun _ -> |
| 28 | +Target "Test" <| fun _ -> |
| 29 | + let nunitRunnerDir = lazy ((getNugetPackage "NUnit.Runners" "2.6.4") @@ "tools") |
42 | 30 | ensureDirectory testDir |
43 | | - !! ("./src/**/bin/" + buildConfiguration + "/*.Tests.dll") |
| 31 | + !! ("./src/**/bin/" + solution.Configuration + "/*.Tests.dll") |
44 | 32 | |> NUnit (fun p -> |
45 | | - {p with |
46 | | - DisableShadowCopy = true; |
47 | | - OutputFile = testDir @@ "TestResult.xml" }) |
48 | | -) |
| 33 | + {p with ToolPath = nunitRunnerDir.Force() |
| 34 | + DisableShadowCopy = true; |
| 35 | + OutputFile = testDir @@ "test.xml" }) |
| 36 | + |
| 37 | +Target "PackUnity" <| fun _ -> |
| 38 | + packUnityPackage "./src/UnityPackage/JsonNet.unitypackage.json" |
| 39 | + packUnityPackage "./src/UnityPackage/JsonNet-Lite.unitypackage.json" |
49 | 40 |
|
50 | | -Target "Package" (fun _ -> |
51 | | - (!! ("src/Newtonsoft.Json/bin/" + buildConfiguration + "/Newtonsoft.Json.dll*")) |> Copy "src/UnityPackage/Assets/Middlewares/JsonNet" |
52 | | - (!! ("src/Newtonsoft.Json/bin/" + buildConfiguration + "Lite/Newtonsoft.Json.dll*")) |> Copy "src/UnityPackageLite/Assets/Middlewares/JsonNet" |
53 | | - (!! ("src/Newtonsoft.Json.Tests/bin/" + buildConfiguration + "/Newtonsoft.Json.Tests.dll*")) |> Copy "src/UnityPackage/Assets/Editor" |
54 | | - Unity (Path.GetFullPath "src/UnityPackage") "-executeMethod PackageBuilder.BuildPackage" |
55 | | - Unity (Path.GetFullPath "src/UnityPackageLite") "-executeMethod PackageBuilder.BuildPackage" |
56 | | - (!! "src/UnityPackage/*.unitypackage") |> Seq.iter (fun p -> MoveFile binDir p) |
57 | | - (!! "src/UnityPackageLite/*.unitypackage") |> Seq.iter (fun p -> MoveFile binDir p) |
58 | | -) |
| 41 | +Target "Pack" <| fun _ -> () |
59 | 42 |
|
60 | | -Target "Help" (fun _ -> |
61 | | - List.iter printfn [ |
62 | | - "usage:" |
63 | | - "build [target]" |
64 | | - "" |
65 | | - " Targets for building:" |
66 | | - " * Build Build" |
67 | | - " * Test Test" |
68 | | - " * Package Build Unity Package" |
69 | | - ""] |
70 | | -) |
| 43 | +Target "CI" <| fun _ -> () |
71 | 44 |
|
72 | | -// --------------------------------------------------------------------------- Dependency |
| 45 | +Target "Help" <| fun _ -> |
| 46 | + showUsage solution (fun _ -> None) |
73 | 47 |
|
74 | | -// Build order |
75 | 48 | "Clean" |
| 49 | + ==> "Restore" |
76 | 50 | ==> "Build" |
77 | 51 | ==> "Test" |
78 | | - ==> "Package" |
79 | 52 |
|
80 | | -RunTargetOrDefault "Package" |
| 53 | +"Build" ==> "PackUnity" |
| 54 | +"PackUnity" ==> "Pack" |
| 55 | + |
| 56 | +"Test" ==> "CI" |
| 57 | +"Pack" ==> "CI" |
| 58 | + |
| 59 | +RunTargetOrDefault "Help" |
0 commit comments