// Gets the runtime graph specified in the path.
 // returns null if an error is hit. A valid runtime graph otherwise.
 private RuntimeGraph GetRuntimeGraph(string runtimeGraphPath)
 {
     if (File.Exists(runtimeGraphPath))
     {
         try
         {
             using (var stream = File.OpenRead(runtimeGraphPath))
             {
                 var runtimeGraph = JsonRuntimeFormat.ReadRuntimeGraph(stream);
                 return(runtimeGraph);
             }
         }
         catch (Exception e)
         {
             _logger.Log(
                 RestoreLogMessage.CreateError(
                     NuGetLogCode.NU1007,
                     string.Format(CultureInfo.CurrentCulture,
                                   Strings.Error_ProjectRuntimeJsonIsUnreadable,
                                   runtimeGraphPath,
                                   e.Message)));
         }
     }
     else
     {
         _logger.Log(
             RestoreLogMessage.CreateError(
                 NuGetLogCode.NU1007,
                 string.Format(CultureInfo.CurrentCulture,
                               Strings.Error_ProjectRuntimeJsonNotFound,
                               runtimeGraphPath)));
     }
     return(null);
 }
Exemple #2
0
        private async Task <bool> ResolutionSucceeded(IEnumerable <RestoreTargetGraph> graphs, IList <DownloadDependencyResolutionResult> downloadDependencyResults, RemoteWalkContext context, CancellationToken token)
        {
            var graphSuccess = true;

            foreach (var graph in graphs)
            {
                if (graph.Conflicts.Any())
                {
                    graphSuccess = false;

                    foreach (var conflict in graph.Conflicts)
                    {
                        var graphName = DiagnosticUtility.FormatGraphName(graph);

                        var message = string.Format(CultureInfo.CurrentCulture, Strings.Log_ResolverConflict,
                                                    conflict.Name,
                                                    string.Join(", ", conflict.Requests),
                                                    graphName);

                        _logger.Log(RestoreLogMessage.CreateError(NuGetLogCode.NU1106, message, conflict.Name, graph.TargetGraphName));
                    }
                }

                if (graph.Unresolved.Count > 0)
                {
                    graphSuccess = false;
                }
            }

            if (!graphSuccess)
            {
                // Log message for any unresolved dependencies
                await UnresolvedMessages.LogAsync(graphs, context, context.Logger, token);
            }

            var ddSuccess = downloadDependencyResults.All(e => e.Unresolved.Count == 0);

            if (!ddSuccess)
            {
                await UnresolvedMessages.LogAsync(downloadDependencyResults, context.RemoteLibraryProviders, context.CacheContext, context.Logger, token);
            }

            return(graphSuccess && ddSuccess);
        }