選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

55 行
2.1 KiB

  1. using System;
  2. using System.IO;
  3. using System.Xml;
  4. using FlubuCore.Context;
  5. using FlubuCore.Scripting.Attributes;
  6. namespace BuildScript
  7. {
  8. [Reference("System.Xml.XmlDocument, System.Xml, Version=4.0.0.0, Culture=neutral, publicKeyToken=b77a5c561934e089")]
  9. public partial class BuildScript
  10. {
  11. public BuildVersion FetchBuildVersion(ITaskContext context)
  12. {
  13. var content = System.IO.File.ReadAllText(RootDirectory.CombineWith("build/version.props"));
  14. XmlDocument doc = new XmlDocument();
  15. doc.LoadXml(content);
  16. var versionMajor = doc.DocumentElement.SelectSingleNode("/Project/PropertyGroup/VersionMajor").InnerText;
  17. var versionMinor = doc.DocumentElement.SelectSingleNode("/Project/PropertyGroup/VersionMinor").InnerText;
  18. var versionPatch = doc.DocumentElement.SelectSingleNode("/Project/PropertyGroup/VersionPatch").InnerText;
  19. var versionQuality = doc.DocumentElement.SelectSingleNode("/Project/PropertyGroup/VersionQuality").InnerText;
  20. versionQuality = string.IsNullOrWhiteSpace(versionQuality) ? null : versionQuality;
  21. var suffix = versionQuality;
  22. bool isCi = false;
  23. bool isTagged = false;
  24. if (!context.BuildSystems().IsLocalBuild)
  25. {
  26. isCi = true;
  27. bool isTagAppveyor = context.BuildSystems().AppVeyor().IsTag;
  28. if (context.BuildSystems().RunningOn == BuildSystemType.AppVeyor && isTagAppveyor ||
  29. context.BuildSystems().RunningOn == BuildSystemType.TravisCI && string.IsNullOrWhiteSpace(context.BuildSystems().Travis().TagName))
  30. {
  31. isTagged = true;
  32. }
  33. }
  34. if (!isTagged)
  35. {
  36. suffix += (isCi ? "preview-" : "dv-") + CreateStamp();
  37. }
  38. suffix = string.IsNullOrWhiteSpace(suffix) ? null : suffix;
  39. var version = new BuildVersion(int.Parse(versionMajor), int.Parse(versionMinor), int.Parse(versionPatch), versionQuality);
  40. version.Suffix = suffix;
  41. return version;
  42. }
  43. }
  44. }