Пример #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Tries to find the buildfile based on the passed in path
        /// </summary>
        /// <param name="path">Path of the solution</param>
        /// ------------------------------------------------------------------------------------
        private string RetrieveBuildFile(string path)
        {
            using (var options = new AddinOptions(Parent))
            {
                // try the solution path
                var buildFile = path != null ?
                    Path.Combine(Path.GetDirectoryName(path), options.Buildfile) : string.Empty;
                if (File.Exists(buildFile))
                    return buildFile;

                // try to find the right base directory based on the project path
                foreach (var baseDir in options.BaseDirectories)
                {
                    var dirToTest = baseDir + "\\";
                    if (path == null || path.ToLower().StartsWith(dirToTest.ToLower()))
                    {
                        return Path.GetFullPath(Path.Combine(baseDir, options.Buildfile));
                    }
                }

                // no success, so take first base directory that we have, or just build file
                return Path.GetFullPath(options.BaseDirectories.Length > 0 &&
                    Directory.Exists(options.BaseDirectories[0])?
                    Path.Combine(options.BaseDirectories[0], options.Buildfile) :
                    options.Buildfile);
            }
        }
        /// ------------------------------------------------------------------------------------------
        /// <summary>
        /// Checks for new updates.
        /// </summary>
        /// ------------------------------------------------------------------------------------------
        private void CheckForUpdates()
        {
            using (var options = new AddinOptions(this))
            {
                // find the update file
                if (options.BaseDirectories == null)
                    return;

                var i = 0;
                var updater = string.Empty;
                for (; i < options.BaseDirectories.Length; i++)
                {
                    updater = Path.Combine(options.BaseDirectories[i], @"Bin\VS Addins\FwVsUpdateChecker.exe");
                    if (File.Exists(updater))
                        break;
                }
                if (i >= options.BaseDirectories.Length || string.IsNullOrEmpty(updater))
                    return;

                using (var process = new 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();
                }
            }
        }