99using O2 . Kernel . ExtensionMethods ;
1010using O2 . DotNetWrappers . DotNet ;
1111using O2 . DotNetWrappers . ExtensionMethods ;
12+ using NuGet ;
13+ using NuGet . Common ;
14+ //O2Ref:NuGet\NutGet.exe
1215//Installer:NuGet_Installer.cs!NuGet\NutGet.exe
1316
1417namespace O2 . XRules . Database . APIs
1518{
1619 public class API_NuGet
1720 {
18- public string NuGet_Exe { get ; set ; }
21+ // public string NuGet_Exe { get; set;}
1922 //public string NuGet_Exe_DownloadUrl { get; set;}
23+ public Program NuGet_Program { get ; set ; }
24+ public Console NuGet_Console { get ; set ; }
2025
2126 public API_NuGet ( )
2227 {
23- this . NuGet_Exe = PublicDI . config . ToolsOrApis
24- . pathCombine ( "NuGet" ) . createDir ( )
25- . pathCombine ( "NuGet.exe" ) ;
26- //this.NuGet_Exe_DownloadUrl = "http://download-codeplex.sec.s-msft.com/Download/Release?ProjectName=nuget&DownloadId=412077&FileTime=129851621946970000&Build=19310";
27- //this.checkInstall();*/
28+ //this.NuGet_Exe = PublicDI.config.ToolsOrApis
29+ // .pathCombine("NuGet").createDir()
30+ // .pathCombine("NuGet.exe");
31+
2832 }
2933
30- public string execute ( string command )
34+ public API_NuGet SetUp ( )
3135 {
32- return this . NuGet_Exe . startProcess_getConsoleOut ( command ) ;
36+ NuGet_Program = new Program ( ) ;
37+ NuGet_Console = new Console ( ) ;
3338 }
39+ /*public string execute(string command)
40+ {
41+ return this.NuGet_Exe.startProcess_getConsoleOut(command);
42+ }*/
3443 }
3544
3645 public static class API_NuGet_ExtensionMethods
3746 {
38- /*public static API_NuGet checkInstall(this API_NuGet nuGet)
39- {
40- if (nuGet.NuGet_Exe.fileExists())
41- "[API_NuGet] found NuGet.exe: {0}".info(nuGet.NuGet_Exe);
42- else
43- {
44- "[API_NuGet] NuGet.exe not found, so downloading it".debug();
45- nuGet.NuGet_Exe_DownloadUrl.download(nuGet.NuGet_Exe);
46- }
47- return nuGet;
48- }*/
47+
48+ }
49+
50+ /*public static class API_NuGet_ExtensionMethods
51+ {
4952
5053 public static string list(this API_NuGet nuGet, string filter)
5154 {
@@ -74,5 +77,129 @@ public static string push(this API_NuGet nuGet, string pathToNuSpec)
7477 return nuGet.execute("Push " + pathToNuSpec);
7578 return "[API_NuGet] could not find provided NuSpec file: {0}".error(pathToNuSpec);
7679 }
80+ }*/
81+ }
82+
83+ /*
84+
85+ panel.clear().add_ConsoleOut(false); // adds a console out viewer
86+
87+ var program = new Program();
88+ var console = new NuGet.Common.Console();
89+ console.WriteLine("Testing NuGet Console out");
90+
91+ Action<Command> setupCommand =
92+ (command)=>{
93+ // this.Settings = Settings.LoadDefaultSettings(this.FileSystem);
94+ var defaultSettings = Settings.LoadDefaultSettings(command.FileSystem);
95+ command.prop("Settings", defaultSettings);
96+
97+ //this.SourceProvider = PackageSourceBuilder.CreateSourceProvider(this.Settings);
98+ var sourceProvider = (IPackageSourceProvider)"NuGet.exe".assembly()
99+ .type("PackageSourceBuilder")
100+ .invokeStatic("CreateSourceProvider",
101+ defaultSettings);
102+ command.prop("SourceProvider", sourceProvider);
103+
104+ //SettingsCredentialProvider defaultCredentialProvider
105+ // = new SettingsCredentialProvider(new ConsoleCredentialProvider(this.Console),
106+ // this.SourceProvider, this.Console);
107+ var defaultCredentialProvider = new SettingsCredentialProvider(
108+ new ConsoleCredentialProvider(command.Console),
109+ sourceProvider, command.Console);
110+
111+ HttpClient.DefaultCredentialProvider = defaultCredentialProvider;
112+
113+ //this.RepositoryFactory = new CommandLineRepositoryFactory(this.Console);
114+ command.prop("RepositoryFactory", new CommandLineRepositoryFactory(command.Console));
115+ };
116+
117+ var tempDir = "_NuGet".tempDir(false);
118+ var fileSystem = new PhysicalFileSystem(tempDir);
119+ program.invoke("Initialize", fileSystem, console);
120+
121+ var commands = program.Commands
122+ .ToDictionary((command)=> command.CommandAttribute.CommandName);
123+ var listCommand = (ListCommand)commands["list"];
124+
125+ setupCommand(listCommand);
126+
127+ var start = DateTime.Now;
128+ "Starting download of Metadata".info();
129+ var packages = listCommand.GetPackages().toList(); // force download of all metadata
130+ "Metadata completed in {0} for {1} packages".debug(start.duration_to_Now(), packages.size());
131+
132+ packages.script_Me("_packages");
133+
134+ return "Continue on scriptMe";
135+
136+ //return "done. packages size = {0} sharedPackageRepository size = {1}"
137+ // .format(packages.size(), sharedPackageRepository.GetPackages().size());
138+
139+
140+ return "done";
141+
142+
143+
144+
145+
146+
147+ Web.Https.ignoreServerSslErrors();
148+
149+ return listCommand.GetPackages().take(250);
150+
151+ "before".info();
152+ var sw = new Stopwatch();
153+ sw.Start();
154+ //using System.Diagnostics
155+ listCommand.GetPackages().take(5500);
156+ "after".info();
157+ sw.Stop();
158+ return sw.Elapsed.str();
159+
160+
161+
162+ //using NuGet
163+ //using NuGet.Common
164+ //using NuGet.Commands
165+ //O2Ref:NuGet/Nuget.exe
166+
167+ */
168+
169+
170+ /*
171+
172+ var tempDir = "_NuGet".tempDir(false);
173+
174+ var packages = (List<IPackage>)_packages;
175+
176+ var start = DateTime.Now;
177+ var sharedPackageRepository = new SharedPackageRepository(tempDir);
178+ var count = 0;
179+ var errors = new List<IPackage>();
180+ foreach(var package in packages) // download the nupkg files
181+ {
182+ try
183+ {
184+ "[{0}/{1}] fetching package {2}".info(++count, packages.size(), package.Id);
185+ sharedPackageRepository.AddPackage(package);
186+ }
187+ catch(Exception ex)
188+ {
189+ errors.add(package);
190+ ex.log("in package: {0}".info(package.Id));
77191 }
78- }
192+ }
193+
194+ "Completed download of all packages in {0}".debug(start.duration_to_Now());
195+ "There where {0} errors".error(errors.size());
196+ return errors;
197+ //using NuGet
198+ //using NuGet.Common
199+ //using NuGet.Commands
200+ //O2Ref:NuGet/Nuget.exe
201+ //O2Ref:mscorlib.dll
202+ //O2Tag_SetInvocationParametersToDynamic
203+ //O2Ref:Microsoft.CSharp.dll
204+
205+ */
0 commit comments