OSDN Git Service

na-get-lib,UninstallStringのmsiexec引数が/Xとなっていない時の対処
[applistation/AppliStation.git] / na-get-lib / NaGet.Packages.Install / Uninstallation.cs
index 930bfb7..045a206 100644 (file)
@@ -80,11 +80,26 @@ namespace NaGet.Packages.Install
                                throw new ApplicationException(string.Format("Could not found {0}install script", Silent? "silent " : ""));\r
                        }\r
                        \r
-                       if (File.Exists(uninstallString)) {\r
+                       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
+                                       NaGet.Utils.ConvertToDataReceivedEventHandler(OutputDataReceived),\r
+                                       NaGet.Utils.ConvertToDataReceivedEventHandler(ErrorDataReceived)) ) {\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
+                                       NaGet.Utils.ConvertToDataReceivedEventHandler(OutputDataReceived),\r
+                                       NaGet.Utils.ConvertToDataReceivedEventHandler(ErrorDataReceived)) ) {\r
+                                       \r
                                        hProcess.WaitForExit();\r
                                        \r
                                        exitValue = hProcess.ExitCode;\r