build-helpers.fsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. module BuildHelpers
  2. open Fake
  3. open Fake.XamarinHelper
  4. open System
  5. open System.IO
  6. open System.Linq
  7. let Exec command args =
  8. let result = Shell.Exec(command, args)
  9. if result <> 0 then failwithf "%s exited with error %d" command result
  10. let RestorePackages solutionFile =
  11. Exec "tools/NuGet/NuGet.exe" ("restore " + solutionFile)
  12. solutionFile |> RestoreComponents (fun defaults -> {defaults with ToolPath = "tools/xpkg/xamarin-component.exe" })
  13. let RunNUnitTests dllPath xmlPath =
  14. Exec "tools/NUnit/nunit-console" (dllPath + " -xml=" + xmlPath)
  15. TeamCityHelper.sendTeamCityNUnitImport xmlPath
  16. let RunUITests appPath =
  17. let testAppFolder = Path.Combine("tests/Calculator.UITests", "testapps")
  18. if Directory.Exists(testAppFolder) then Directory.Delete(testAppFolder, true)
  19. Directory.CreateDirectory(testAppFolder) |> ignore
  20. let testAppPath = Path.Combine(testAppFolder, DirectoryInfo(appPath).Name)
  21. Directory.Move(appPath, testAppPath)
  22. RestorePackages "Calculator.sln"
  23. MSBuild "tests/Calculator.UITests/bin/Debug" "Build" [ ("Configuration", "Debug"); ("Platform", "Any CPU") ] [ "tests/Calculator.UITests/Calculator.UITests.csproj" ] |> ignore
  24. RunNUnitTests "tests/Calculator.UITests/bin/Debug/Calculator.UITests.dll" "tests/Calculator.UITests/bin/Debug/testresults.xml"
  25. let GetBuildCounter (str:Option<string>) =
  26. match str with
  27. | Some(v) -> v
  28. | None -> "Local"