コード例 #1
0
        private bool TryGetRunnerEx(string prerequisitePath, out string runnerPath)
        {
            runnerPath = null;
            var runnerName = GetRunnerName();

            Trace.Verbose("Prerequisite.TryGetRunnerEx: `{0}`", runnerName);

            if (string.IsNullOrEmpty(prerequisitePath))
            {
                prerequisitePath = GetDefaultDownloadPath();
            }

            prerequisitePath = Path.Combine(prerequisitePath, Name);

            Trace.Verbose("Prerequisite.TryGetRunnerEx: Looking for latest version at `{0}`...", prerequisitePath);

            if (!Directory.Exists(prerequisitePath))
            {
                Trace.Verbose("Prerequisite.TryGetRunnerEx: No runner found.");
                return(false);
            }

            var    packageVersion2 = SemanticVersion.Version2;
            string latestOriginal  = null;       // the latest found version including build meta-info

            NuGet.SemanticVersion latest = null; // the latest parsed version w/o meta-info
            foreach (var versionFolder in Directory.GetDirectories(prerequisitePath))
            {
                var sVer = Path.GetFileName(versionFolder);
                Trace.Verbose("Prerequisite.TryGetRunnerEx:   {0}", sVer);

                var ver = NuGet.SemanticVersion.TryParse(sVer);
                if (ver == null || ver.Version2 != packageVersion2)
                {
                    continue;
                }

                if (latest == null || latest.CompareTo(ver) <= 0)
                {
                    latestOriginal = sVer;
                    latest         = ver;
                }
            }

            if (latestOriginal != null)
            {
                runnerPath = Path.Combine(prerequisitePath, latestOriginal, runnerName);
                Trace.Verbose("Prerequisite.TryGetRunnerEx: Checking `{0}`...", runnerPath);
                return(File.Exists(runnerPath));
            }

            Trace.Verbose("Prerequisite.TryGetRunnerEx: No runner found.");
            return(false);
        }
コード例 #2
0
 protected PrerequisiteBase(string name, NuGet.SemanticVersion semanticVersion)
 {
     Name            = name;
     SemanticVersion = semanticVersion;
 }