2 using NaGet.Packages.Install;
\r
3 using NaGet.Packages;
\r
6 namespace NaGet.SubCommands
\r
8 public class NaGetUninstall : NaGetTaskSet
\r
10 private bool done = false;
\r
12 private int currentTaskSetIndex = -1;
\r
14 private PackageListsManager pkgListMan;
\r
17 ///
\83A
\83\93\83C
\83\93\83X
\83g
\81[
\83\8b\82·
\82é
\83p
\83b
\83P
\81[
\83W
\r
19 public Uninstallation[] Uninstallations;
\r
22 ///
\83R
\83\93\83X
\83g
\83\89\83N
\83^
\r
24 /// <param name="pkgs">
\83A
\83\93\83C
\83\93\83X
\83g
\81[
\83\8b\82·
\82é
\83p
\83b
\83P
\81[
\83W</param>
\r
25 public NaGetUninstall(PackageListsManager pkgMan, InstalledPackage[] pkgs)
\r
27 pkgListMan = pkgMan;
\r
29 Uninstallations = new Uninstallation[pkgs.Length];
\r
30 for (int i = 0; i < pkgs.Length; i++) {
\r
31 Uninstallations[i] = new Uninstallation(pkgs[i]);
\r
34 initializeMainTaskSetNames();
\r
38 ///
\83R
\83\93\83X
\83g
\83\89\83N
\83^
\r
40 /// <param name="uninstallations">
\83A
\83\93\83C
\83\93\83X
\83g
\81[
\83\8b\8f\88\97\9d\82Ì
\94z
\97ñ</param>
\r
41 public NaGetUninstall(PackageListsManager pkgMan, Uninstallation[] uninstallations)
\r
43 pkgListMan = pkgMan;
\r
45 Uninstallations = uninstallations;
\r
46 initializeMainTaskSetNames();
\r
49 private void initializeMainTaskSetNames()
\r
51 System.Collections.Generic.List<string> taskSetNames = new System.Collections.Generic.List<string>();
\r
53 for (int i =0; i < Uninstallations.Length; i++) {
\r
54 taskSetNames.Add(string.Format("
\83A
\83\93\83C
\83\93\83X
\83g
\81[
\83\8b: {0}", Uninstallations[i].ToString()));
\r
56 taskSetNames.Add(string.Format("
\83\8a\83X
\83g
\8dX
\90V: {0}", NaGet.Env.ArchiveInstalledPackageListFile));
\r
57 taskSetNames.Add(string.Format("
\83\8a\83X
\83g
\8dX
\90V: {0}", NaGet.Env.SystemInstalledPackageListFile));
\r
59 TaskSetNames = taskSetNames.ToArray();
\r
62 public override void Run()
\r
64 currentTaskSetIndex ++;
\r
65 RaiseTaskSetEvent(NaGetTaskSetEventType.STARTED, "
\83A
\83\93\83C
\83\93\83X
\83g
\81[
\83\8b\8f\88\97\9d\8aJ
\8en");
\r
67 foreach (Uninstallation uninst in Uninstallations) {
\r
68 RaiseTaskSetEvent(NaGetTaskSetEventType.STARTED_TASKSET, uninst.ToString());
\r
70 if (uninst.Installed) {
\r
72 uninst.OutputDataReceived += this.ReceivedOutputData;
\r
73 uninst.ErrorDataReceived += this.ReceivedErrorData;
\r
74 int exitCode = uninst.Uninstall();
\r
75 if (exitCode != 0) {
\r
76 RaiseTaskSetEvent(NaGetTaskSetEventType.WARNING, "
\83A
\83\93\83C
\83\93\83X
\83g
\81[
\83\8b\82ª
\90³
\8fí
\82É
\8fI
\82¦
\82Ä
\82¢
\82È
\82¢
\89Â
\94\
\90«
\82ª
\82 \82è
\82Ü
\82·
\81B
\83v
\83\8d\83Z
\83X
\82Ì
\8fI
\97¹
\83R
\81[
\83h:"+exitCode);
\r
78 } catch (Exception e) {
\r
79 RaiseTaskSetEvent(NaGetTaskSetEventType.ERROR, e.Message);
\r
84 RaiseTaskSetEvent(NaGetTaskSetEventType.WARNING, string.Format("{0}
\82Í
\8aù
\82É
\83A
\83\93\83C
\83\93\83X
\83g
\81[
\83\8b\82³
\82ê
\82Ä
\82¢
\82é
\82©
\81A
\83\
\83t
\83g
\82Ì
\91¶
\8dÝ
\82ð
\8am
\94F
\82Å
\82«
\82Ü
\82¹
\82ñ
\82Å
\82µ
\82½", uninst));
\r
87 RaiseTaskSetEvent(NaGetTaskSetEventType.COMPLETED_TASKSET, uninst.ToString());
\r
94 RaiseTaskSetEvent(NaGetTaskSetEventType.COMPLETED, "
\8fI
\97¹", 100);
\r
97 private void runLocalUpdate()
\r
99 //
\83C
\83\93\83X
\83g
\81[
\83\8b\83g
\83\8a\83X
\83g
\82Ì
\8dX
\90V
\r
100 RaiseTaskSetEvent(NaGetTaskSetEventType.STARTED_TASKSET, TaskSetNames[currentTaskSetIndex]);
\r
101 pkgListMan.DetectInstalledPkgs();
\r
102 pkgListMan.SaveInstalledPackageList();
\r
103 RaiseTaskSetEvent(NaGetTaskSetEventType.COMPLETED_TASKSET, TaskSetNames[currentTaskSetIndex]);
\r
104 currentTaskSetIndex++;
\r
106 //
\83V
\83X
\83e
\83\80\82É
\83C
\83\93\83X
\83g
\81[
\83\8b\82³
\82ê
\82Ä
\82¢
\82é
\83\8a\83X
\83g
\82Ì
\8dX
\90V
\r
107 RaiseTaskSetEvent(NaGetTaskSetEventType.STARTED_TASKSET, TaskSetNames[currentTaskSetIndex]);
\r
108 pkgListMan.DetectSystemInstalledPkgs();
\r
109 pkgListMan.SaveSystemInstalledPackageList();
\r
110 RaiseTaskSetEvent(NaGetTaskSetEventType.COMPLETED_TASKSET, TaskSetNames[currentTaskSetIndex]);
\r
111 currentTaskSetIndex++;
\r
114 public override bool Done {
\r
115 get { return done; }
\r
118 public override int CurrentTaskSetIndex {
\r
119 get { return currentTaskSetIndex; }
\r