/// ------------------------------------------------------------------------------------------ /// <summary> /// Checks for new updates. /// </summary> /// ------------------------------------------------------------------------------------------ private void CheckForUpdates() { using (AddinOptions options = new AddinOptions()) { // find the update file if (options.BaseDirectories == null) { return; } int i = 0; string updater = string.Empty; for (; i < options.BaseDirectories.Length; i++) { updater = Path.Combine(options.BaseDirectories[0], @"bin\VS Addins\FwVsUpdateChecker.exe"); if (File.Exists(updater)) { break; } } if (i >= options.BaseDirectories.Length) { return; } System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.FileName = updater; process.StartInfo.CreateNoWindow = true; process.StartInfo.WorkingDirectory = Path.GetDirectoryName(updater); if (Settings.Default.FirstTime) { process.StartInfo.Arguments = "/first " + options.BaseDirectories[i]; } else { process.StartInfo.Arguments = options.BaseDirectories[i]; } process.Start(); if (Settings.Default.FirstTime) { Settings.Default.FirstTime = false; Settings.Default.Save(); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Tries to find the buildfile and fwroot based on the passed in path /// </summary> /// <param name="path">Path</param> /// <param name="buildfile">[out] name and path of the buildfile</param> /// <param name="fwroot">[out] fwroot path</param> /// ------------------------------------------------------------------------------------ private void RetrieveBuildFile(string path, out string buildFile, out string fwroot) { buildFile = string.Empty; fwroot = string.Empty; // try to find the right base directory based on the project path using (AddinOptions options = new AddinOptions()) { buildFile = string.Empty; fwroot = string.Empty; foreach (string baseDir in options.BaseDirectories) { string dirToTest = baseDir + "\\"; if (path.ToLower().StartsWith(dirToTest.ToLower())) { buildFile = Path.GetFullPath(Path.Combine(baseDir, options.Buildfile)); fwroot = baseDir; break; } } // no success, so take first base directory that we have, or just build file if (buildFile == string.Empty) { if (options.BaseDirectories.Length > 0) { fwroot = options.BaseDirectories[0]; buildFile = Path.GetFullPath(Path.Combine(fwroot, options.Buildfile)); } else { buildFile = Path.GetFullPath(options.Buildfile); fwroot = Path.GetDirectoryName(buildFile); } } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Tries to find the buildfile and fwroot based on the passed in path /// </summary> /// <param name="path">Path</param> /// <param name="buildfile">[out] name and path of the buildfile</param> /// <param name="fwroot">[out] fwroot path</param> /// ------------------------------------------------------------------------------------ private void RetrieveBuildFile(string path, out string buildFile, out string fwroot) { buildFile = string.Empty; fwroot = string.Empty; // try to find the right base directory based on the project path using (AddinOptions options = new AddinOptions()) { buildFile = string.Empty; fwroot = string.Empty; foreach(string baseDir in options.BaseDirectories) { string dirToTest = baseDir + "\\"; if (path.ToLower().StartsWith(dirToTest.ToLower())) { buildFile = Path.GetFullPath(Path.Combine(baseDir, options.Buildfile)); fwroot = baseDir; break; } } // no success, so take first base directory that we have, or just build file if (buildFile == string.Empty) { if (options.BaseDirectories.Length > 0) { fwroot = options.BaseDirectories[0]; buildFile = Path.GetFullPath(Path.Combine(fwroot, options.Buildfile)); } else { buildFile = Path.GetFullPath(options.Buildfile); fwroot = Path.GetDirectoryName(buildFile); } } } }
/// ------------------------------------------------------------------------------------------ /// <summary> /// Checks for new updates. /// </summary> /// ------------------------------------------------------------------------------------------ private void CheckForUpdates() { using (AddinOptions options = new AddinOptions()) { // find the update file if (options.BaseDirectories == null) return; int i = 0; string updater = string.Empty; for (; i < options.BaseDirectories.Length; i++) { updater = Path.Combine(options.BaseDirectories[0], @"bin\VS Addins\FwVsUpdateChecker.exe"); if (File.Exists(updater)) break; } if (i >= options.BaseDirectories.Length) return; System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.FileName = updater; process.StartInfo.CreateNoWindow = true; process.StartInfo.WorkingDirectory = Path.GetDirectoryName(updater); if (Settings.Default.FirstTime) process.StartInfo.Arguments = "/first " + options.BaseDirectories[i]; else process.StartInfo.Arguments = options.BaseDirectories[i]; process.Start(); if (Settings.Default.FirstTime) { Settings.Default.FirstTime = false; Settings.Default.Save(); } } }