internal DotnetUtilsResult <string> GetNuGetFallbackFolderPath() { var commandResult = _dotnetCommandService.Run("--list-sdks"); if (commandResult.Success) { var match = _sdkPathRegex.Match(commandResult.StdOut); if (match.Success) { var fallbackPath = _fileSystem.Path.Combine(match.Groups["path"].ToString(), "NuGetFallbackFolder"); if (_fileSystem.Directory.Exists(fallbackPath)) { return(new DotnetUtilsResult <string> { Result = fallbackPath }); } else { return(new DotnetUtilsResult <string>()); } } } return(new DotnetUtilsResult <string> { ErrorMessage = commandResult.StdErr }); }
// Future: Instead of invoking the dotnet CLI to get direct dependencies, once asset file version 3 is available through the Nuget library, // The direct dependencies could be retrieved from the asset file json path: .project.frameworks.<framework>.dependencies private List <(string, string)> GetDirectPackageDependencies(string targetRuntime, string projectFilePath) { var directPackageDependencies = new List <(string, string)>(); var framework = TargetFrameworkToAlias(targetRuntime); if (framework != null) { var output = _dotnetCommandService.Run($"list \"{projectFilePath}\" package --framework {framework}"); var result = output.Success ? output.StdOut : null; if (result != null) { directPackageDependencies = result.Split('\r', '\n').Select(line => line.Trim()) .Where(line => line.StartsWith(">", StringComparison.InvariantCulture)) .Select(line => line.Split(' ', StringSplitOptions.RemoveEmptyEntries)) .Where(parts => parts.Length == 4) .Select(parts => (parts[1], parts[3])) .ToList(); } } return(directPackageDependencies); }