public override bool Execute() { bool anyErrors = false; foreach (ITaskItem binary in Binaries) { string binaryFullPath = binary.GetMetadata("FullPath"); string binaryFileName = Path.GetFileName(binaryFullPath); string version = Regex.Match(binaryFileName, VersionMatchRegex).Groups["semver"].Value; while (BadAtoms.Any(ba => version.Contains(ba))) { foreach (var ba in BadAtoms) { version = version.Replace(ba, ""); } } if (version == "") { Log.LogError($"Could not extract version information from {binaryFileName}"); anyErrors = true; continue; } string destinationFolder = DestinationFolderTemplate.Replace("{version}", version); Directory.CreateDirectory(destinationFolder); File.Copy(binaryFullPath, Path.Combine(destinationFolder, binaryFileName), overwrite: true); PublishedVersion = version; } return(!anyErrors); }
public override bool Execute() { bool anyErrors = false; foreach (ITaskItem binary in Binaries) { string binaryFullPath = binary.GetMetadata("FullPath"); string binaryFileName = Path.GetFileName(binaryFullPath); string version = Regex.Match(binaryFileName, VersionMatchRegex).Groups["semver"].Value; // workaround the RID being included for now - regex needs to be reworked for stable versions if (version.EndsWith("-linux")) { version = version.Substring(0, version.Length - "-linux".Length); } if (version.EndsWith("-osx")) { version = version.Substring(0, version.Length - "-osx".Length); } if (version.Contains("-ubuntu")) { version = version.Substring(0, version.IndexOf("-ubuntu")); } if (version == "") { Log.LogError($"Could not extract version information from {binaryFileName}"); anyErrors = true; continue; } string destinationFolder = DestinationFolderTemplate.Replace("{version}", version); Directory.CreateDirectory(destinationFolder); File.Copy(binaryFullPath, Path.Combine(destinationFolder, binaryFileName), overwrite: true); PublishedVersion = version; } return(!anyErrors); }