Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

83 linhas
3.2 KiB

  1. using System.Collections.Generic;
  2. using FlubuCore.Context;
  3. using FlubuCore.IO;
  4. using FlubuCore.Scripting;
  5. using FlubuCore.Scripting.Attributes;
  6. namespace BuildScript
  7. {
  8. [Include("./build/BuildVersion.cs")]
  9. public partial class BuildScript : DefaultBuildScript
  10. {
  11. protected string ArtifactsDir => RootDirectory.CombineWith("artifacts");
  12. [FromArg("c|configuration")]
  13. public string Configuration { get; set; }
  14. protected BuildVersion BuildVersion { get; set; }
  15. protected List<FileFullPath> ProjectFiles { get; set; }
  16. protected List<FileFullPath> TestProjectFiles { get; set; }
  17. protected override void ConfigureBuildProperties(IBuildPropertiesContext context)
  18. {
  19. context.Properties.Set(BuildProps.SolutionFileName, "CAP.sln");
  20. context.Properties.Set(BuildProps.BuildConfiguration, string.IsNullOrEmpty(Configuration) ? "Release" : Configuration);
  21. }
  22. protected override void BeforeBuildExecution(ITaskContext context)
  23. {
  24. BuildVersion = FetchBuildVersion(context);
  25. TestProjectFiles = context.GetFiles(RootDirectory.CombineWith("test"), "*/*.csproj");
  26. ProjectFiles = context.GetFiles(RootDirectory.CombineWith("src"), "*/*.csproj");
  27. }
  28. protected override void ConfigureTargets(ITaskContext context)
  29. {
  30. var clean = context.CreateTarget("Clean")
  31. .SetDescription("Cleans the output of all projects in the solution.")
  32. .AddCoreTask(x => x.Clean()
  33. .AddDirectoryToClean(ArtifactsDir, true));
  34. var restore = context.CreateTarget("Restore")
  35. .SetDescription("Restores the dependencies and tools of all projects in the solution.")
  36. .DependsOn(clean)
  37. .AddCoreTask(x => x.Restore());
  38. var build = context.CreateTarget("Build")
  39. .SetDescription("Builds all projects in the solution.")
  40. .DependsOn(restore)
  41. .AddCoreTask(x => x.Build()
  42. .InformationalVersion(BuildVersion.VersionWithSuffix()));
  43. var tests = context.CreateTarget("Tests")
  44. .SetDescription("Runs all Cap tests.")
  45. .ForEach(TestProjectFiles,
  46. (projectFile, target) =>
  47. {
  48. target.AddCoreTask(x => x.Test()
  49. .Project(projectFile)
  50. .NoBuild());
  51. });
  52. var pack = context.CreateTarget("Pack")
  53. .SetDescription("Creates nuget packages for Cap.")
  54. .ForEach(ProjectFiles, (projectFile, target) =>
  55. {
  56. target.AddCoreTask(x => x.Pack()
  57. .NoBuild()
  58. .Project(projectFile)
  59. .IncludeSymbols()
  60. .VersionSuffix(BuildVersion.Suffix)
  61. .OutputDirectory(ArtifactsDir));
  62. });
  63. context.CreateTarget("Default")
  64. .SetDescription("Runs all targets.")
  65. .SetAsDefault()
  66. .DependsOn(clean, restore, build, tests, pack);
  67. }
  68. }
  69. }