Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates all files that require an update.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void UpdateFiles()
        {
            bool fAskedUserToExit = false;             // will be set to true as soon as we have asked user

            using (ProgressDialog dlg = new ProgressDialog())
            {
                dlg.ProgressBar.Maximum = m_FilesToUpdate.Length;
                dlg.Show();
                for (int i = 0; i < m_FilesToUpdate.Length && !dlg.ShouldCancel; i++)
                {
                    UpdateFile file = m_FilesToUpdate[i];
                    Trace.WriteLine(DateTime.Now + ": Installing " + file.Name);
                    dlg.InstallText = "Installing " + file.Name;

                    if (file.ExitVs && !fAskedUserToExit)
                    {
                        fAskedUserToExit = true;
                        CloseVs();
                    }

                    try
                    {
                        string extension = Path.GetExtension(file.Name).ToLower();
                        if (extension == ".msi" || extension == ".vsi" || extension == ".vsix")
                        {
                            // Install this file
                            Process process = new Process();
                            process.StartInfo.FileName       = Path.Combine(m_UpdatePath, file.Name);
                            process.StartInfo.CreateNoWindow = true;
                            process.StartInfo.Arguments      = "/quiet";
                            process.Start();
                            process.WaitForExit();
                            Trace.WriteLine(DateTime.Now + ": Exit code: " + process.ExitCode);
                        }
                        else if (extension == ".dll")
                        {
                            // Install in the GAC
                            string  fileName = Path.Combine(m_UpdatePath, file.Name);
                            Publish publish  = new Publish();
                            publish.GacInstall(fileName);
                            Trace.WriteLine(DateTime.Now + ": Installed in GAC");
                        }
                    }
                    catch (Exception e)
                    {
                        Trace.WriteLine(DateTime.Now + ": Got exception installing " +
                                        file.Name + ": " + e.Message);
                        // remove from list of updated files so that we try again
                        m_FileHash.Remove(file.Name);
                    }
                    dlg.ProgressBar.Increment(1);
                }

                RestartVisualStudio(dlg);
                dlg.Close();
            }
        }
Ejemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates all files that require an update.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void UpdateFiles()
        {
            bool fAskedUserToExit = false;             // will be set to true as soon as we have asked user

            using (ProgressDialog dlg = new ProgressDialog())
            {
                dlg.ProgressBar.Maximum = m_FilesToUpdate.Length;
                dlg.Show();
                for (int i = 0; i < m_FilesToUpdate.Length && !dlg.ShouldCancel; i++)
                {
                    UpdateFile file = m_FilesToUpdate[i];
                    Trace.WriteLine(DateTime.Now.ToString() + ": Installing " + file.Name);
                    dlg.InstallText = "Installing " + file.Name;

                    if (file.ExitVs && !fAskedUserToExit)
                    {
                        fAskedUserToExit = true;
                        Process[] processes = Process.GetProcessesByName("devenv");
                        if (processes.Length > 0)
                        {
                            if (MessageBox.Show("Visual Studio needs to close before update can proceed",
                                                "Updates available", MessageBoxButtons.OKCancel) == DialogResult.OK)
                            {
                                ExitVs();
                            }
                            else
                            {
                                Trace.WriteLine(DateTime.Now.ToString() + ": Skipped closing Visual Studio by user's request");
                            }
                        }
                    }

                    try
                    {
                        string extension = Path.GetExtension(file.Name).ToLower();
                        if (extension == ".msi" || extension == ".vsi")
                        {
                            // Install this file
                            Process process = new Process();
                            process.StartInfo.FileName       = Path.Combine(m_UpdatePath, file.Name);
                            process.StartInfo.CreateNoWindow = true;
                            process.StartInfo.Arguments      = "/quiet";
                            process.Start();
                            process.WaitForExit();
                            Trace.WriteLine(DateTime.Now.ToString() + ": Exit code: " + process.ExitCode);
                        }
                        else if (extension == ".dll")
                        {
                            // Install in the GAC
                            string  fileName = Path.Combine(m_UpdatePath, file.Name);
                            Publish publish  = new Publish();
                            publish.GacInstall(fileName);
                            Trace.WriteLine(DateTime.Now.ToString() + ": Installed in GAC");
                        }
                    }
                    catch (Exception e)
                    {
                        Trace.WriteLine(DateTime.Now.ToString() + ": Got exception installing " +
                                        file.Name + ": " + e.Message);
                        // remove from list of updated files so that we try again
                        m_FileHash.Remove(file.Name);
                    }
                    dlg.ProgressBar.Increment(1);
                }

                RestartVisualStudio(dlg);
                dlg.Close();
            }
        }
Ejemplo n.º 3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Updates all files that require an update.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void UpdateFiles()
		{
			bool fAskedUserToExit = false; // will be set to true as soon as we have asked user
			using (ProgressDialog dlg = new ProgressDialog())
			{
				dlg.ProgressBar.Maximum = m_FilesToUpdate.Length;
				dlg.Show();
				for (int i = 0; i < m_FilesToUpdate.Length && !dlg.ShouldCancel; i++)
				{
					UpdateFile file = m_FilesToUpdate[i];
					Trace.WriteLine(DateTime.Now.ToString() + ": Installing " + file.Name);
					dlg.InstallText = "Installing " + file.Name;

					if (file.ExitVs && !fAskedUserToExit)
					{
						fAskedUserToExit = true;
						Process[] processes = Process.GetProcessesByName("devenv");
						if (processes.Length > 0)
						{
							if (MessageBox.Show("Visual Studio needs to close before update can proceed",
							"Updates available", MessageBoxButtons.OKCancel) == DialogResult.OK)
							{
								ExitVs();
							}
							else
							{
								Trace.WriteLine(DateTime.Now.ToString() + ": Skipped closing Visual Studio by user's request");
							}
						}
					}

					try
					{
						string extension = Path.GetExtension(file.Name).ToLower();
						if (extension == ".msi" || extension == ".vsi")
						{
							// Install this file
							Process process = new Process();
							process.StartInfo.FileName = Path.Combine(m_UpdatePath, file.Name);
							process.StartInfo.CreateNoWindow = true;
							process.StartInfo.Arguments = "/quiet";
							process.Start();
							process.WaitForExit();
							Trace.WriteLine(DateTime.Now.ToString() + ": Exit code: " + process.ExitCode);
						}
						else if (extension == ".dll")
						{
							// Install in the GAC
							string fileName = Path.Combine(m_UpdatePath, file.Name);
							Publish publish = new Publish();
							publish.GacInstall(fileName);
							Trace.WriteLine(DateTime.Now.ToString() + ": Installed in GAC");
						}
					}
					catch (Exception e)
					{
						Trace.WriteLine(DateTime.Now.ToString() + ": Got exception installing " +
							file.Name + ": " + e.Message);
						// remove from list of updated files so that we try again
						m_FileHash.Remove(file.Name);
					}
					dlg.ProgressBar.Increment(1);
				}

				RestartVisualStudio(dlg);
				dlg.Close();
			}
		}
Ejemplo n.º 4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates all files that require an update.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void UpdateFiles()
        {
            bool fAskedUserToExit = false; // will be set to true as soon as we have asked user
            using (ProgressDialog dlg = new ProgressDialog())
            {
                dlg.ProgressBar.Maximum = m_FilesToUpdate.Length;
                dlg.Show();
                for (int i = 0; i < m_FilesToUpdate.Length && !dlg.ShouldCancel; i++)
                {
                    UpdateFile file = m_FilesToUpdate[i];
                    Trace.WriteLine(DateTime.Now + ": Installing " + file.Name);
                    dlg.InstallText = "Installing " + file.Name;

                    if (file.ExitVs && !fAskedUserToExit)
                    {
                        fAskedUserToExit = true;
                        CloseVs();
                    }

                    try
                    {
                        string extension = Path.GetExtension(file.Name).ToLower();
                        if (extension == ".msi" || extension == ".vsi" || extension == ".vsix")
                        {
                            // Install this file
                            Process process = new Process();
                            process.StartInfo.FileName = Path.Combine(m_UpdatePath, file.Name);
                            process.StartInfo.CreateNoWindow = true;
                            process.StartInfo.Arguments = "/quiet";
                            process.Start();
                            process.WaitForExit();
                            Trace.WriteLine(DateTime.Now + ": Exit code: " + process.ExitCode);
                        }
                        else if (extension == ".dll")
                        {
                            // Install in the GAC
                            string fileName = Path.Combine(m_UpdatePath, file.Name);
                            Publish publish = new Publish();
                            publish.GacInstall(fileName);
                            Trace.WriteLine(DateTime.Now + ": Installed in GAC");
                        }
                    }
                    catch (Exception e)
                    {
                        Trace.WriteLine(DateTime.Now + ": Got exception installing " +
                            file.Name + ": " + e.Message);
                        // remove from list of updated files so that we try again
                        m_FileHash.Remove(file.Name);
                    }
                    dlg.ProgressBar.Increment(1);
                }

                RestartVisualStudio(dlg);
                dlg.Close();
            }
        }