public static void RefreshConfigCountry(CountryParameter item, DirectoryInfo rootPathTemp) { Output.WriteLine($"{item.Name} updating in the version {item.OnlineVersion}"); // Download Output.WriteLine($"Download"); string filename = Path.Combine(rootPathTemp.FullName, string.Format(@"Black.Beard.Calendarium.{0}.zip", item.Name)); var task = BbClientHttp.DownloadAsync(string.Format(@"https://www.nuget.org/api/v2/package/Black.Beard.Calendarium.{0}/{1}", item.Name, item.OnlineVersion), filename); task.Wait(); // Unzip Output.WriteLine($"Uncompress"); var dir = rootPathTemp.CreateSubdirectory(string.Format(@"Black.Beard.Calendarium.{0}", item.Name)); FileInfo f = new FileInfo(filename); f.UnzipFromFile(dir.FullName); // copy configurations Output.WriteLine($"Save"); DirectoryInfo p = new DirectoryInfo(Path.Combine(dir.FullName, @"content\Configuration\Countries")); var file = p.GetFiles("*.json").FirstOrDefault(); var target = new FileInfo(Path.Combine(Constants.RootPathConfig.FullName, item.Name) + ".json"); if (target.Exists) { target.Delete(); } file.CopyTo(target.FullName); item.LocalVersion = item.OnlineVersion; }
public static CommandLineApplication CommandDownloadNuget(this CommandLineApplication app) { var cmd = app.Command("download", config => { config.Description = "Download nuget at " + Constants.urlNuget; config.HelpOption(HelpFlag); var validator = new GroupArgument(config, false); config.OnExecute(() => { if (validator.Evaluate() > 0) { return(2); } var uri = new Uri(Constants.urlNuget); BbClientHttp cli = new BbClientHttp(uri); try { if (Constants.NugetFile.Exists) { Output.WriteLine("remove current version of nuget.exe in " + Constants.NugetFile.Directory.FullName); Constants.NugetFile.Delete(); } } catch (Exception ex1) { throw new Exception("failed to remove current version of nuget.exe", ex1); } try { Output.WriteLine("download lastest version of nuget.exe in " + Constants.NugetFile.Directory.FullName); BbClientHttp.DownloadAsync(uri, Constants.NugetFile.FullName).Wait(); } catch (Exception ex2) { throw new Exception("failed to to downlod nuget.exe", ex2); } Output.WriteLine("download successfull"); Result = Constants.NugetFile; return(0); }); }); return(app); }