Created
September 27, 2017 00:13
-
-
Save agc93/f55121cfb0612312d3ae5ac339e91890 to your computer and use it in GitHub Desktop.
An experimental alternative approach to the Cake Downlink plugin intended to be more generalised
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool Match(Path path, VersionSpec version) | |
{ | |
var platform = GetPlatform(version); | |
_logger.LogTrace("Invoking Cake matcher for '{0}' (inferred '{1}' platform); matching against '{2}'", version.Summary, platform, path.ToString()); | |
var name = path.GetFilenameWithoutExtension(); | |
return name.Contains($"Cake-{platform}") && name.Contains($"-{version}"); | |
} | |
private string GetPlatform(VersionSpec version) { | |
var minor = int.Parse(version.ToString().TrimStart('v').Split('.')[1]); | |
if (minor > 16 && version.Platform == "any") { | |
// defaults to .NET Framework | |
return $"bin-net4"; | |
} | |
return version.Platform == "any" | |
? "bin" // pre 0.16.0 any is fine | |
: $"bin-{version.Platform}"; // post 0.16.0 with explicit platform | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment