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)); } } // Resolve all of the potential projects foreach (var searchPath in _searchPaths) { var directory = new DirectoryInfo(searchPath); if (!directory.Exists) { continue; } foreach (var projectDirectory in directory.EnumerateDirectories()) { // The name of the folder is the project _projects[projectDirectory.Name] = new ProjectInformation { Name = projectDirectory.Name, FullPath = projectDirectory.FullName }; } } }
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); }
public static string ResolveRepositoryPath(string rootDirectory) { // Order // 1. KRE_PACKAGES environment variable // 2. global.json { "packages": "..." } // 3. NuGet.config repositoryPath (maybe)? // 4. %userprofile%\.kpm\packages var krePackages = Environment.GetEnvironmentVariable("KRE_PACKAGES"); if (!string.IsNullOrEmpty(krePackages)) { return(krePackages); } GlobalSettings settings; if (GlobalSettings.TryGetGlobalSettings(rootDirectory, out settings) && !string.IsNullOrEmpty(settings.PackagesPath)) { return(Path.Combine(rootDirectory, settings.PackagesPath)); } var profileDirectory = Environment.GetEnvironmentVariable("USERPROFILE"); if (string.IsNullOrEmpty(profileDirectory)) { profileDirectory = Environment.GetEnvironmentVariable("HOME"); } return(Path.Combine(profileDirectory, ".kpm", "packages")); }
public static string ResolveRepositoryPath(string rootDirectory) { // Order // 1. EnvironmentNames.Packages environment variable // 2. global.json { "packages": "..." } // 3. NuGet.config repositoryPath (maybe)? // 4. {DefaultLocalRuntimeHomeDir}\packages var runtimePackages = Environment.GetEnvironmentVariable(EnvironmentNames.Packages); if (!string.IsNullOrEmpty(runtimePackages)) { return(runtimePackages); } GlobalSettings settings; if (GlobalSettings.TryGetGlobalSettings(rootDirectory, out settings) && !string.IsNullOrEmpty(settings.PackagesPath)) { return(Path.Combine(rootDirectory, settings.PackagesPath)); } var profileDirectory = Environment.GetEnvironmentVariable("USERPROFILE"); if (string.IsNullOrEmpty(profileDirectory)) { profileDirectory = Environment.GetEnvironmentVariable("HOME"); } return(Path.Combine(profileDirectory, Constants.DefaultLocalRuntimeHomeDir, "packages")); }
public NuGetDependencyResolver(string packagesPath, string rootDir = null) { // Runtime already ensures case-sensitivity, so we don't need package ids in accurate casing here _repository = new PackageRepository(packagesPath, checkPackageIdCase: false); Dependencies = Enumerable.Empty <LibraryDescription>(); if (!string.IsNullOrEmpty(rootDir)) { GlobalSettings.TryGetGlobalSettings(rootDir, out _globalSettings); } }
private IEnumerable <string> ResolveSearchPaths(string projectPath, string rootPath) { var paths = new List <string> { Path.GetDirectoryName(projectPath) }; GlobalSettings global; if (GlobalSettings.TryGetGlobalSettings(rootPath, out global)) { foreach (var sourcePath in global.SourcePaths) { paths.Add(Path.Combine(rootPath, sourcePath)); } } return(paths.Distinct()); }