public static void GetLatestGithubReleaseViaWebclient(VpmGlobals vpmg) { /* * var baseurl = "https://api.github.com"; * var initreguest = string.Format("/repos/{0}/{1}/releases", "mrvux", "dx11-vvvv"); * Console.WriteLine(baseurl + initreguest); * var filename = string.Format("vvvv-packs-dx11-{0}.zip", vpmg.VVVV.Architecture); * * var client = new WebClient(); * client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); * Console.WriteLine("Fetching releases from github"); * * var stream = client.OpenRead(baseurl + initreguest); * var reader = new StreamReader(stream).ReadToEnd(); * var jsondata = JArray.Parse(reader); * var jsonres = jsondata.Children().ToArray()[0]; * var asset = jsonres["assets"].Where(a => a["name"].ToString() == filename).ToArray()[0]; * * Console.WriteLine("Downloading {0} from {1}", filename, jsonres["tag_name"]); * * vpmg.Download( * asset["browser_download_url"].ToString(), * Path.Combine(vpmg.VPM.TempDir, filename) * ); * vpmg.Extract(Path.Combine(vpmg.VPM.TempDir, filename), vpmg.Pack.TempDir); * vpmg.CopyDir( * vpmg.Pack.TempDir, * vpmg.VVVV.Dir * ); */ }
public void Install() { foreach (var d in Dependencies) { d.Install(); } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Installing " + Name); Console.ResetColor(); var vpmglobal = new VpmGlobals(this); var assemblies = VpmConfig.Instance.ReferencedAssemblies; var nugetassemblies = new List <Assembly>(); if (NugetPackages != null && NugetPackages.Count > 0) { Console.WriteLine("Initializing Nuget for this pack"); var packdir = Path.Combine(TempDir, "NugetPackages"); var packdirinfo = Directory.CreateDirectory(packdir); var repo = VpmConfig.Instance.DefaultNugetRepository; var packman = new PackageManager(repo, packdir); packman.PackageInstalled += (sender, args) => { Console.WriteLine("Installed " + args.Package.Id); }; for (int i = 0; i < NugetPackages.Count; i++) { var packnode = NugetPackages[i]; Console.WriteLine("Installing Nuget Package " + packnode.InnerText); var version = packnode.Attributes?["version"]?.Value; var packages = repo.FindPackagesById(packnode.InnerText); IPackage package = null; foreach (var p in packages) { bool versioncheck = p.IsLatestVersion; if (version != null) { versioncheck = SemanticVersion.Parse(version) == p.Version; } if (versioncheck) { package = p; break; } } if (package == null) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("No nuget package found with those conditions"); Console.ResetColor(); } else { packman.InstallPackage(package, false, true); } } var dlls = packdirinfo.EnumerateDirectories().Where(info => info.GetDirectories("lib").Length > 0).Select(packinfo => { var libdir = packinfo.GetDirectories("lib")[0]; var netversion = libdir.EnumerateDirectories("net*").Max(libinfo => { var regexc = new Regex(@"net(\d*?$)"); var matches = regexc.Matches(libinfo.Name); if (matches.Count == 0) { return(0); } return(int.Parse(matches[0].Groups[1].Value)); }); return(libdir.GetDirectories("net" + netversion)[0].GetFiles("*.dll")); }); foreach (var fileInfos in dlls) { foreach (var file in fileInfos) { try { var ass = Assembly.LoadFrom(file.FullName); Console.WriteLine("Loaded assembly " + file.Name); if (!(assemblies.Contains(ass) || nugetassemblies.Contains(ass))) { nugetassemblies.Add(ass); } } catch { } } } } try { if (VpmConfig.Instance.Arguments.UseEmbeddedScript) { ScriptDebug.SelectedDebugScript(vpmglobal); } else { CSharpScript.EvaluateAsync(InstallScript, globals: vpmglobal, options: ScriptOptions.Default.WithReferences(assemblies.Concat(nugetassemblies))); } } catch (Exception e) { if (e is CompilationErrorException) { var ee = (CompilationErrorException)e; Console.WriteLine("Compilation error:"); Console.WriteLine(string.Join(Environment.NewLine, ee.Diagnostics)); } else { Console.WriteLine("Script error:"); Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } Console.WriteLine("Press any key to exit..."); Console.ReadKey(true); VpmUtils.CleanUp(); Environment.Exit(0); } }