hProcess.WaitForExit();\r
break;\r
case InstallerType.ARCHIVE:\r
- // TODO ハックな実装?\r
- if (File.Exists("archive-inst.exe")) {\r
- string argument = string.Format("-i \"{0}\" \"{1}\"", installerfile, this.InstalledPackage.Name);\r
- ProcessStartInfo procInfo = new ProcessStartInfo(Path.GetFullPath("archive-inst.exe"), argument);\r
- procInfo.UseShellExecute = false;\r
- procInfo.CreateNoWindow = true;\r
- procInfo.WorkingDirectory = Environment.CurrentDirectory;\r
- \r
- hProcess = NaGet.Utils.ProcessStartWithOutputCapture(procInfo, this.OutputDataReceived, this.ErrorDataReceived);\r
- hProcess.WaitForExit();\r
- break;\r
- }\r
- throw new NotImplementedException("Not implemented archive installation yet");\r
- //break;\r
+ string argument = string.Format("-i \"{0}\" \"{1}\"", installerfile, this.InstalledPackage.Name);\r
+ hProcess = createExtractArchiveProcess(argument,\r
+ this.OutputDataReceived,\r
+ this.ErrorDataReceived);\r
+ break;\r
default:\r
throw new NotImplementedException("Not implemented archive installation yet");\r
}\r
}\r
}\r
}\r
-\r
+ \r
/// <summary>\r
/// インストーラ等を起動してインストール作業を行う\r
/// </summary>\r
if (InstalledPackage.ArchivedInstaller) {\r
Directory.CreateDirectory(tempDir);\r
\r
- // 64bit対策で展開も別プロセスで\r
- // TODO エラーとかの出力を取得できたりとかできるように\r
- if (File.Exists("archive-inst.exe")) {\r
- string argument = string.Format("-t \"{0}\" \"{1}\"", installerFile, tempDir);\r
- ProcessStartInfo info = new ProcessStartInfo(Path.GetFullPath("archive-inst.exe"), argument);\r
- info.UseShellExecute = false;\r
- info.WorkingDirectory = Environment.CurrentDirectory;\r
- \r
- using (Process hProcess = Process.Start(info)) {\r
- hProcess.WaitForExit();\r
- \r
- if (hProcess.ExitCode != 0) {\r
- throw new ApplicationException("Extract error " + installerFile + " to " + tempDir);\r
- }\r
+ string argument = string.Format("-t \"{0}\" \"{1}\"", installerFile, tempDir);\r
+ using (Process hProcess = createExtractArchiveProcess(argument,\r
+ this.OutputDataReceived,\r
+ this.ErrorDataReceived)) {\r
+ hProcess.WaitForExit();\r
+ \r
+ if (hProcess.ExitCode != 0) {\r
+ throw new ApplicationException("Extract error " + installerFile + " to " + tempDir);\r
}\r
- } else {\r
- throw new ApplicationException(string.Format("archive-inst.exe not found in {0}!", Environment.CurrentDirectory));\r
}\r
\r
// System.Text.StringBuilder output = new System.Text.StringBuilder(1024);\r
return (list.Count > 0)? list[0] : null;\r
}\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 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
+ 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})", InstalledPackage.Name, InstalledPackage.Version);\r