Bari.Plugins.Nuget.Tools.NuGet.InstallPackage C# (CSharp) Method

InstallPackage() public method

Installs a package and returns the path to the DLLs to be linked
public InstallPackage ( string name, string version, IFileSystemDirectory root, string relativeTargetDirectory, bool dllsOnly, NugetLibraryProfile maxProfile ) : IEnumerable>.Tuple
name string Package name
version string Package version, if null or empty then the latest one will be used
root IFileSystemDirectory Root directory for storing the downloaded packages
relativeTargetDirectory string Path relative to root where the downloaded package should be placed
dllsOnly bool If true, only the DLLs will be returned, otherwise all the files in the package
maxProfile NugetLibraryProfile Maximum allowed profile
return IEnumerable>.Tuple
        public Tuple<string, IEnumerable<string>> InstallPackage(string name, string version, IFileSystemDirectory root, string relativeTargetDirectory, bool dllsOnly, NugetLibraryProfile maxProfile)
        {
            if (String.IsNullOrWhiteSpace(version))
                Run(root, "install", name, "-o", "\""+relativeTargetDirectory+"\"", "-Verbosity", Verbosity);
            else
                Run(root, "install", name, "-Version", version, "-o", "\"" + relativeTargetDirectory + "\"", "-Verbosity", Verbosity);

            var result = new List<string>(); // root relative paths
            string commonRoot = String.Empty; // root relative path

            var localRoot = root as LocalFileSystemDirectory;
            if (localRoot != null)
            {
                var pkgRoot = new DirectoryInfo(Path.Combine(localRoot.AbsolutePath, relativeTargetDirectory));

                var modRoot = FindDirectory(pkgRoot, name);

                if (modRoot != null)
                {
                    var libRoot = modRoot.GetDirectories("lib", SearchOption.TopDirectoryOnly).FirstOrDefault();
                    var contentRoot = modRoot.GetDirectories("content", SearchOption.TopDirectoryOnly).FirstOrDefault();
                    commonRoot = GetRelativePath(modRoot.FullName, localRoot);

                    if (libRoot != null)
                    {
                        AddDlls(libRoot, result, localRoot, maxProfile);
                        commonRoot = GetRelativePath(libRoot.FullName, localRoot);
                    }
                    if (contentRoot != null && !dllsOnly)
                    {
                        AddContents(contentRoot, result, localRoot);

                        if (libRoot == null)
                            commonRoot = GetRelativePath(contentRoot.FullName, localRoot);
                    }
                }
            }

            log.DebugFormat("Returning common root {0}", commonRoot);
            return Tuple.Create(commonRoot, result.AsEnumerable());
        }