/// <summary> /// Get a binary version for the executing assembly /// </summary> /// <returns>A BinaryVersion</returns> internal static BinaryVersion GetCurrentBinaryVersion() { // If we're looking at dailies, latest build version will simply be // the current build version without a build or revision, ex. 0.6 var v = Assembly.GetExecutingAssembly().GetName().Version; return(BinaryVersion.FromString(string.Format("{0}.{1}.{2}", v.Major, v.Minor, v.Build))); }
private BinaryVersion GetLatestInstallVersion() { var dynamoInstallations = GetDynamoInstalls(); var latestVersion = dynamoInstallations.Select(GetDynamoVersion).OrderBy(s => s).LastOrDefault(); return(latestVersion == null ? null : BinaryVersion.FromString(latestVersion.ToString())); }
/// <summary> /// Callback for the UpdateRequest's UpdateDataAvailable event. /// Reads the request's data, and parses for available versions. /// If a more recent version is available, the UpdateInfo object /// will be set. /// </summary> /// <param name="request">An instance of an update request.</param> public void UpdateDataAvailable(IAsynchronousRequest request) { UpdateInfo = null; //If there is error data or the request data is empty //bail out. if (!string.IsNullOrEmpty(request.Error) || string.IsNullOrEmpty(request.Data)) { _versionCheckInProgress = false; return; } XNamespace ns = "http://s3.amazonaws.com/doc/2006-03-01/"; XDocument doc = null; using (TextReader td = new StringReader(request.Data)) { doc = XDocument.Load(td); } var bucketresult = doc.Element(ns + "ListBucketResult"); var builds = bucketresult.Descendants(ns + "LastModified"). OrderByDescending(x => DateTime.Parse(x.Value)). Where(x => x.Parent.Value.Contains("DynamoInstall")). Select(x => x.Parent); var xElements = builds as XElement[] ?? builds.ToArray(); if (!xElements.Any()) { _versionCheckInProgress = false; return; } var latestBuild = xElements.First(); var latestBuildFileName = latestBuild.Element(ns + "Key").Value; var latestBuildDownloadUrl = Path.Combine(Configurations.UpdateDownloadLocation, latestBuildFileName); var latestBuildVersion = BinaryVersion.FromString(Path.GetFileNameWithoutExtension(latestBuildFileName).Remove(0, 13)); if (latestBuildVersion > ProductVersion) { UpdateInfo = new AppVersionInfo() { Version = latestBuildVersion, VersionInfoURL = Configurations.UpdateDownloadLocation, InstallerURL = latestBuildDownloadUrl }; } _versionCheckInProgress = false; }
public static BinaryVersion GetProductVersion() { if (null != productVersion) { return(productVersion); } var executingAssemblyName = Assembly.GetExecutingAssembly().GetName(); productVersion = BinaryVersion.FromString(executingAssemblyName.Version.ToString()); return(productVersion); }
/// <summary> /// Get a BinaryVersion from a file path. /// </summary> /// <param name="installNameBase">The base install name.</param> /// <param name="filePath">The path name of the file.</param> /// <returns>A BinaryVersion or null if one can not be parse from the file path.</returns> internal static BinaryVersion GetBinaryVersionFromFilePath(string installNameBase, string filePath) { // Filename format is DynamoInstall0.7.1.YYYYMMDDT0000.exe var index = filePath.IndexOf(installNameBase, StringComparison.Ordinal); if (index < 0) { return(null); } // Skip past the 'installNameBase' since we are only interested // in getting the version numbers that come after the base name. var fileName = Path.GetFileNameWithoutExtension(filePath); var version = fileName.Substring(index + installNameBase.Length); var splits = version.Split(new [] { "." }, StringSplitOptions.RemoveEmptyEntries); if (splits.Count() < 3) // This can be 4 if it includes revision number. { return(null); } ushort major, minor, build; if (!ushort.TryParse(splits[0], out major)) { return(null); } if (!ushort.TryParse(splits[1], out minor)) { return(null); } if (!ushort.TryParse(splits[2], out build)) { return(null); } return(BinaryVersion.FromString(string.Format("{0}.{1}.{2}.0", major, minor, build))); }
/// <summary> /// Get a BinaryVersion from a file path. /// </summary> /// <param name="installNameBase">The base install name.</param> /// <param name="filePath">The path name of the file.</param> /// <returns>A BinaryVersion or null if one can not be parse from the file path.</returns> internal static BinaryVersion GetBinaryVersionFromFilePath(string installNameBase, string filePath) { // Filename format is DynamoInstall0.7.1.YYYYMMDDT0000.exe if (!filePath.Contains(installNameBase)) { return(null); } var fileName = Path.GetFileNameWithoutExtension(filePath).Replace(installNameBase, ""); var splits = fileName.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries); if (splits.Count() < 3) { return(null); } var major = ushort.Parse(splits[0]); var minor = ushort.Parse(splits[1]); var build = ushort.Parse(splits[2]); return(BinaryVersion.FromString(string.Format("{0}.{1}.{2}.0", major, minor, build))); }