string filePath = NaGet.Utils.GetRelativePath(fakeTargetDir, file);\r
string targetFilePath = Path.Combine(targetDir, filePath);\r
if (File.Exists(targetFilePath)) {\r
- File.SetAttributes(targetFilePath, FileAttributes.Normal);\r
- File.Delete(targetFilePath);\r
+ try {\r
+ File.SetAttributes(targetFilePath, FileAttributes.Normal);\r
+ File.Delete(targetFilePath);\r
+ } catch (UnauthorizedAccessException e) {\r
+ throw new IOException(string.Format("Access denied '{0}'", targetFilePath), e);\r
+ }\r
}\r
File.Move(file, targetFilePath);\r
}\r
}\r
}\r
\r
- NaGet.Utils.SetAttributeRecursive(targetDir, FileAttributes.Normal);\r
- Directory.Delete(targetDir, true);\r
+ try {\r
+ NaGet.Utils.SetAttributeRecursive(targetDir, FileAttributes.Normal);\r
+ Directory.Delete(targetDir, true);\r
+ } catch (UnauthorizedAccessException) {\r
+ Console.Error.WriteLine("W: could not complete to delete '{0}': Permission denied", targetDir);\r
+ Environment.Exit(1);\r
+ }\r
}\r
\r
private static void parseMainArguments(string[] args, out string arcFile, out string targetDir, out Package package)\r
throw new ApplicationException(string.Format("Could not found {0}install script", Silent? "silent " : ""));\r
}\r
\r
- if (UninstalledPackage.UninstallInfo.WindowsInstaller &&\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
- NaGet.Utils.ConvertToDataReceivedEventHandler(OutputDataReceived),\r
- NaGet.Utils.ConvertToDataReceivedEventHandler(ErrorDataReceived)) ) {\r
+ this.OutputDataReceived,\r
+ this.ErrorDataReceived) ) {\r
\r
if (NaGet.Env.InstallProcessOnBackground) {\r
try {\r
// 単独のファイルの場合\r
using (Process hProcess = NaGet.Utils.ProcessStartWithOutputCapture(\r
new ProcessStartInfo(uninstallString),\r
- NaGet.Utils.ConvertToDataReceivedEventHandler(OutputDataReceived),\r
- NaGet.Utils.ConvertToDataReceivedEventHandler(ErrorDataReceived)) ) {\r
+ this.OutputDataReceived,\r
+ this.ErrorDataReceived) ) {\r
\r
if (NaGet.Env.InstallProcessOnBackground) {\r
try {\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