Example #1
0
        private void Initialize(string projectPath, string rootPath)
        {
            _searchPaths.Add(new DirectoryInfo(projectPath).Parent.FullName);

            GlobalSettings global;

            if (GlobalSettings.TryGetGlobalSettings(rootPath, out global))
            {
                foreach (var sourcePath in global.ProjectSearchPaths)
                {
                    _searchPaths.Add(Path.Combine(rootPath, sourcePath));
                }
            }

            Func <DirectoryInfo, ProjectInformation> dirInfoToProjectInfo = d => new ProjectInformation
            {
                // The name of the folder is the project
                Name     = d.Name,
                FullPath = d.FullName
            };

            // Resolve all of the potential projects
            _projects = _searchPaths.Select(path => new DirectoryInfo(path))
                        .Where(d => d.Exists)
                        .SelectMany(d => new[] { d }.Concat(d.EnumerateDirectories()))
                        .Distinct(new DirectoryInfoFullPathComparator())
                        .Select(dirInfoToProjectInfo)
                        .ToLookup(d => d.Name);
        }
Example #2
0
        public static string ResolveRepositoryPath(string rootDirectory)
        {
            // Order
            // 1. global.json { "packages": "..." }
            // 2. EnvironmentNames.Packages environment variable
            // 3. NuGet.config repositoryPath (maybe)?
            // 4. {DefaultLocalRuntimeHomeDir}\packages

            GlobalSettings settings;

            if (GlobalSettings.TryGetGlobalSettings(rootDirectory, out settings) &&
                !string.IsNullOrEmpty(settings.PackagesPath))
            {
                return(Path.Combine(rootDirectory, settings.PackagesPath));
            }

            var runtimePackages = Environment.GetEnvironmentVariable(EnvironmentNames.Packages);

            if (string.IsNullOrEmpty(runtimePackages))
            {
                runtimePackages = Environment.GetEnvironmentVariable(EnvironmentNames.DnxPackages);
            }

            if (!string.IsNullOrEmpty(runtimePackages))
            {
                return(runtimePackages);
            }

            var profileDirectory = Environment.GetEnvironmentVariable("USERPROFILE");

            if (string.IsNullOrEmpty(profileDirectory))
            {
                profileDirectory = Environment.GetEnvironmentVariable("HOME");
            }

            return(Path.Combine(profileDirectory, Constants.DefaultLocalRuntimeHomeDir, "packages"));
        }