Build.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using Nuke.Common;
  2. using Nuke.Common.Execution;
  3. using Nuke.Common.IO;
  4. using Nuke.Common.ProjectModel;
  5. using Nuke.Common.Tools.DotNet;
  6. using Nuke.Common.Utilities.Collections;
  7. using static Nuke.Common.IO.FileSystemTasks;
  8. using static Nuke.Common.Tools.DotNet.DotNetTasks;
  9. [UnsetVisualStudioEnvironmentVariables]
  10. class Build : NukeBuild {
  11. public static int Main() => Execute<Build>(x => x.Publish);
  12. [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
  13. readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
  14. [Solution] readonly Solution Solution;
  15. AbsolutePath SourceDirectory => RootDirectory / "src";
  16. AbsolutePath OutputDirectory => RootDirectory / "output";
  17. Target Clean => _ => _
  18. .Before(Restore)
  19. .Executes(() => {
  20. SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory);
  21. EnsureCleanDirectory(OutputDirectory);
  22. });
  23. Target Restore => _ => _
  24. .Executes(() => {
  25. DotNetRestore(s => s
  26. .SetProjectFile(Solution));
  27. });
  28. Target Compile => _ => _
  29. .DependsOn(Restore)
  30. .Executes(() => {
  31. DotNetBuild(s => s
  32. .SetProjectFile(Solution)
  33. .SetConfiguration(Configuration)
  34. .EnableNoRestore());
  35. });
  36. Target Test => _ => _
  37. .DependsOn(Compile)
  38. .Executes(() => {
  39. DotNetTest(s => s
  40. .SetProjectFile(Solution)
  41. .EnableNoRestore());
  42. });
  43. Target Publish => _ => _
  44. .DependsOn(Test)
  45. .Executes(() => {
  46. DotNetPublish(s => s
  47. .SetProject(SourceDirectory / "Robware.Api.Projects/Robware.Api.Projects.csproj")
  48. .SetConfiguration(Configuration)
  49. .SetOutput(OutputDirectory));
  50. });
  51. }