public async Task AddPackage(string name, Action <string>?statusCallback = null) { if (Nugets == null) { throw new InvalidOperationException("Packages can be only added to the global references collection"); } var duration = Stopwatch.StartNew(); var pkg = await Nugets.Add(name, statusCallback); AddAssemblies(Nugets.Assemblies.ToArray()); duration.Stop(); PackageLoaded?.Invoke(this, new PackageLoadedEventArgs(pkg.Id, pkg.Version.ToNormalizedString(), duration.Elapsed)); }
/// <summary> /// Adds the libraries from the given nuget package to the list of assemblies. /// If version is not provided. It automatically picks up the latest version. /// </summary> public async Task AddPackage(string name) { var duration = Stopwatch.StartNew(); if (Nugets == null) { throw new InvalidOperationException("Packages can be only added to the global references collection"); } var pkg = await Nugets.Add(name); Assemblies = Assemblies.Union(Nugets.Assemblies).ToImmutableArray(); Reset(); duration.Stop(); PackageLoaded?.Invoke(this, new PackageLoadedEventArgs(pkg.Id, pkg.Version.ToNormalizedString(), duration.Elapsed)); }
public void AddPackage(string pkgname, bool force = false) { Uri uri = new Uri(mSource, "/api/" + pkgname); var fileName = GetPath(pkgname); if (File.Exists(fileName) && !force) { var npkg = new AndroidPackage(pkgname); mPackages.Add(npkg); var args = new PackageDownloadedEventArgs(); args.Package = npkg; PackageLoaded?.Invoke(this, args); return; } using (var wc = new WebClient()) { wc.DownloadFile(uri, fileName); var npkg = new AndroidPackage(pkgname); mPackages.Add(npkg); var args = new PackageDownloadedEventArgs(); args.Package = npkg; PackageDownloaded?.Invoke(this, args); } }