OSDN Git Service

na-get-lib,UninstallStringのmsiexec引数が/Xとなっていない時の対処
authorttp <ttp@users.sourceforge.jp>
Sun, 16 Mar 2008 11:12:55 +0000 (11:12 +0000)
committerttp <ttp@users.sourceforge.jp>
Sun, 16 Mar 2008 11:12:55 +0000 (11:12 +0000)
git-svn-id: http://localhost/svn/AppliStation/trunk@876 34ed2c89-c49f-4a4b-abdb-c318350108cf

na-get-lib/NaGet.Packages.Install/UninstallInformation.cs
na-get-lib/NaGet.Packages.Install/Uninstallation.cs

index 49e00fb..6bf1543 100644 (file)
@@ -75,6 +75,11 @@ namespace NaGet.Packages.Install
                public bool IsOSPatch;\r
                \r
                /// <summary>\r
+               /// アンインストールにmsiexecを使うか否か\r
+               /// </summary>\r
+               public bool WindowsInstaller = false;\r
+               \r
+               /// <summary>\r
                /// ソフトをインストールした日付\r
                /// </summary>\r
                [XmlIgnore]\r
@@ -129,6 +134,7 @@ namespace NaGet.Packages.Install
                        uninstInfo.CanModify = ((int) regKey.GetValue("NoModify", 1)) != 1;\r
                        uninstInfo.CanRepair = ((int) regKey.GetValue("NoRepair", 1)) != 1;\r
                        uninstInfo.CanRemove = ((int) regKey.GetValue("NoRemove", 1)) != 1; \r
+                       uninstInfo.WindowsInstaller = ((int) regKey.GetValue("WindowsInstaller", 0)) == 1; \r
                        uninstInfo.IsSystemComponent = ((int) regKey.GetValue("SystemComponent", 0)) > 0;\r
                        uninstInfo.IsOSPatch = ((string) regKey.GetValue("ParentKeyName", null)) == "OperatingSystem";\r
                        try {\r
@@ -213,6 +219,7 @@ namespace NaGet.Packages.Install
                        uninstInfo.CanModify = false;\r
                        uninstInfo.CanRepair = false;\r
                        uninstInfo.CanRemove = true;\r
+                       uninstInfo.WindowsInstaller = false;\r
                        uninstInfo.IsSystemComponent = false;\r
                        uninstInfo.IsOSPatch = false;\r
                        uninstInfo.InstallLocation = null;\r
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