public object Any(AddPackageAsReference request) { return(new AddPackageAsReferenceResponse { Assemblies = NugetUtils.RestorePackage(DataContext, AppData.NugetPackagesDirectory, request.PackageId, request.Version) }); }
private List <AssemblyReference> AddReferencesFromPackages(List <AssemblyReference> references, string packages, out List <AssemblyReference> normalizedReferences) { try { var tmpReferences = new List <AssemblyReference>(); if (references != null) { tmpReferences.AddRange(references); } if (!string.IsNullOrEmpty(packages)) { PackageCollection tmpPackages = null; var serializer = new XmlSerializer(typeof(PackageCollection)); var arr = packages.ToAsciiBytes(); using (var ms = new MemoryStream(arr)) { tmpPackages = (PackageCollection)serializer.Deserialize(ms); } foreach (var package in tmpPackages.Packages) { //install it tmpReferences.AddRange(NugetUtils.RestorePackage(DataContext, AppData.NugetPackagesDirectory, package.Id, package.Version)); } } //distinct by name tmpReferences = tmpReferences.GroupBy(a => a.Name).Select(g => g.First()).ToList(); //normalizedReferences - references with original path normalizedReferences = tmpReferences .Select(r => new AssemblyReference().PopulateWith(r)) .ToList(); foreach (var reference in tmpReferences) { if (!Path.IsPathRooted(reference.Path)) { var rootPath = VirtualFiles.RootDirectory.RealPath; reference.Path = Path.Combine(rootPath, AppData.NugetPackagesDirectory, reference.Path); } } return(tmpReferences); } catch (Exception ex) { throw ex; } }
public object Any(InstallNugetPackage request) { NugetUtils.InstallPackage(DataContext, AppData.NugetPackagesDirectory, request.PackageId, request.Version); return(new InstallNugetPackageResponse()); }