public bool Installed\r
{\r
get {\r
- if (Directory.Exists(UninstalledPackage.UninstallInfo.InstallLocation)) {\r
- return true;\r
- } else if (UninstalledPackage.Type == InstallerType.ARCHIVE) {\r
- return false;\r
- }\r
- \r
- foreach (UninstallInformation info in RegistriedUninstallers.Uninstallers) {\r
- Match match = Regex.Match(info.DisplayName, UninstalledPackage.UninstallerKey);\r
- \r
- if (match.Success) {\r
- return true;\r
+ if ((UninstalledPackage.Type == InstallerType.ARCHIVE)\r
+ || UninstalledPackage.Type == InstallerType.ITSELF) {\r
+ return Directory.Exists(UninstalledPackage.UninstallInfo.InstallLocation);\r
+ } else {\r
+ foreach (UninstallInformation info in RegistriedUninstallers.Uninstallers) {\r
+ if (! string.IsNullOrEmpty(UninstalledPackage.UninstallerKey)) {\r
+ Match match = Regex.Match(info.DisplayName, UninstalledPackage.UninstallerKey);\r
+ \r
+ if (match.Success) {\r
+ return true;\r
+ }\r
+ }\r
}\r
}\r
return false;\r
}\r
\r
/// <summary>\r
- /// アンインストーラ等を起動してアンインストール作業を行う\r
+ /// アンインストーラー等を起動してアンインストール作業を行う\r
/// </summary>\r
- /// <returns>アンインストーラの終了コード</returns>\r
+ /// <returns>ã\82¢ã\83³ã\82¤ã\83³ã\82¹ã\83\88ã\83¼ã\83©ã\83¼ã\81®çµ\82äº\86ã\82³ã\83¼ã\83\89</returns>\r
public int Uninstall()\r
{\r
if (! Installed) {\r
throw new ApplicationException(string.Format("Could not found {0}install script", Silent? "silent " : ""));\r
}\r
\r
- if (File.Exists(uninstallString)) {\r
+ if (UninstalledPackage.Type == InstallerType.ARCHIVE\r
+ || UninstalledPackage.Type == InstallerType.ITSELF) {\r
+ \r
+ string argument = string.Format("-x \"{0}\"", UninstalledPackage.Name);\r
+ using (Process hProcess = createExtractArchiveProcess(argument,\r
+ this.OutputDataReceived,\r
+ this.ErrorDataReceived)) {\r
+ \r
+ if (NaGet.Env.InstallProcessOnBackground) {\r
+ try {\r
+ hProcess.PriorityClass = ProcessPriorityClass.Idle;\r
+ } catch (Exception) {}\r
+ }\r
+ \r
+ hProcess.WaitForExit();\r
+ \r
+ exitValue = hProcess.ExitCode;\r
+ }\r
+ } else if (UninstalledPackage.UninstallInfo.WindowsInstaller &&\r
+ Regex.Match(uninstallString.Substring("MsiExec.exe /I".Length),\r
+ @"^\{[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}\}$").Success) {\r
+ string guid = uninstallString.Substring("MsiExec.exe /I".Length);\r
+ using (Process hProcess = NaGet.Utils.ProcessStartWithOutputCapture(\r
+ new ProcessStartInfo("msiexec", string.Format("/X{0}", guid)),\r
+ this.OutputDataReceived,\r
+ this.ErrorDataReceived) ) {\r
+ \r
+ if (NaGet.Env.InstallProcessOnBackground) {\r
+ try {\r
+ hProcess.PriorityClass = ProcessPriorityClass.Idle;\r
+ } catch (Exception) {}\r
+ }\r
+ \r
+ hProcess.WaitForExit();\r
+ \r
+ exitValue = hProcess.ExitCode;\r
+ }\r
+ } else if (File.Exists(uninstallString)) {\r
// 単独のファイルの場合\r
- using (Process hProcess = NaGet.Utils.ProcessStartWithOutputCapture(new ProcessStartInfo(uninstallString),\r
- NaGet.Utils.ConvertToDataReceivedEventHandler(OutputDataReceived),\r
- NaGet.Utils.ConvertToDataReceivedEventHandler(ErrorDataReceived)) ) {\r
+ using (Process hProcess = NaGet.Utils.ProcessStartWithOutputCapture(\r
+ new ProcessStartInfo(uninstallString),\r
+ this.OutputDataReceived,\r
+ this.ErrorDataReceived) ) {\r
+ \r
+ if (NaGet.Env.InstallProcessOnBackground) {\r
+ try {\r
+ hProcess.PriorityClass = ProcessPriorityClass.Idle;\r
+ } catch (Exception) {}\r
+ }\r
+ \r
hProcess.WaitForExit();\r
\r
exitValue = hProcess.ExitCode;\r
} else {\r
ProcessStartInfo procInfo = new ProcessStartInfo(null, uninstallString);\r
procInfo.UseShellExecute = false;\r
- if (UninstalledPackage.Type == InstallerType.ARCHIVE) {\r
- procInfo.CreateNoWindow = true;\r
- }\r
+ procInfo.CreateNoWindow = true;\r
using (NaGet.InteropServices.CreateProcessCaller p = new NaGet.InteropServices.CreateProcessCaller(procInfo)) {\r
+ \r
+ if (NaGet.Env.InstallProcessOnBackground) {\r
+ try {\r
+ p.PriorityClass = ProcessPriorityClass.Idle;\r
+ } catch (Exception) {}\r
+ }\r
+ \r
p.WaitForExit();\r
\r
exitValue = p.ExitCode;\r
return exitValue;\r
}\r
\r
+ /// <summary>\r
+ /// アーカイブファイルのアンインストールを行う\r
+ /// </summary>\r
+ /// <param name="archiveInstArgs">"archive-inst.exe"への引数</param>\r
+ /// <param name="outputReceived">標準出力用リスナ(null可)</param>\r
+ /// <param name="errorReceived">エラー出力用リスナ(null可)</param>\r
+ /// <returns>実行プロセス</returns>\r
+ private static Process createExtractArchiveProcess(string archiveInstArgs,\r
+ EventHandler<NaGet.Utils.AnyDataEventArgs<string>> outputReceived,\r
+ EventHandler<NaGet.Utils.AnyDataEventArgs<string>> errorReceived)\r
+ {\r
+ string archiveInstExe = Path.GetFullPath("archive-inst.exe");\r
+ if (! File.Exists(archiveInstExe)) {\r
+ string errMsg = string.Format("\"{0}\" does not found!");\r
+ throw new ApplicationException(errMsg,\r
+ new FileNotFoundException(errMsg, archiveInstExe));\r
+ }\r
+ \r
+ \r
+ \r
+ ProcessStartInfo procInfo = new ProcessStartInfo(archiveInstExe, archiveInstArgs);\r
+ procInfo.UseShellExecute = false;\r
+ procInfo.CreateNoWindow = true;\r
+ procInfo.WorkingDirectory = Environment.CurrentDirectory;\r
+ \r
+ return NaGet.Utils.ProcessStartWithOutputCapture(procInfo, outputReceived, errorReceived);\r
+ }\r
+ \r
public override string ToString()\r
{\r
return string.Format("{0}({1})", UninstalledPackage.Name, UninstalledPackage.Version);\r