Exemplo n.º 1
0
        public async Task <IReadOnlyList <PackageSpec> > GetPackageSpecsAsync(DependencyGraphCacheContext context)
        {
            var(dgSpec, _) = await GetPackageSpecsAndAdditionalMessagesAsync(context);

            return(dgSpec);
        }
Exemplo n.º 2
0
        public async Task <IReadOnlyList <PackageSpec> > GetPackageSpecsAsync(DependencyGraphCacheContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            // Some projects like website project don't have project file.
            // Return empty list for this case.
            if (string.IsNullOrEmpty(ProjectSystem.ProjectFileFullPath))
            {
                return(new List <PackageSpec>());
            }

            PackageSpec packageSpec = null;

            if (!context.PackageSpecCache.TryGetValue(ProjectSystem.ProjectFileFullPath, out packageSpec))
            {
                packageSpec = new PackageSpec(new List <TargetFrameworkInformation>
                {
                    new TargetFrameworkInformation
                    {
                        FrameworkName = ProjectSystem.TargetFramework
                    }
                });
                packageSpec.Name     = ProjectSystem.ProjectName;
                packageSpec.FilePath = ProjectSystem.ProjectFileFullPath;

                // A packages.config project does not follow the typical restore flow so there is no need to add package
                // dependencides to the package spec. Packages.config package restoration is done elsewhere.

                var metadata = new ProjectRestoreMetadata();
                packageSpec.RestoreMetadata = metadata;

                metadata.ProjectStyle      = ProjectStyle.Unknown;
                metadata.ProjectPath       = ProjectSystem.ProjectFileFullPath;
                metadata.ProjectName       = ProjectSystem.ProjectName;
                metadata.ProjectUniqueName = ProjectSystem.ProjectFileFullPath;

                var references = (await ProjectServices
                                  .ReferencesReader
                                  .GetProjectReferencesAsync(context.Logger, CancellationToken.None))
                                 .ToList();
                if (references != null && references.Count > 0)
                {
                    // Add framework group
                    var frameworkGroup = new ProjectRestoreMetadataFrameworkInfo(ProjectSystem.TargetFramework);
                    metadata.TargetFrameworks.Add(frameworkGroup);

                    foreach (var reference in references)
                    {
                        // This reference applies to all frameworks
                        // Include/exclude flags are not possible for this project type
                        frameworkGroup.ProjectReferences.Add(reference);
                    }
                }

                context.PackageSpecCache.Add(MSBuildProjectPath, packageSpec);
            }

            return(new[] { packageSpec });
        }
Exemplo n.º 3
0
 public virtual Task <IReadOnlyList <ProjectRestoreReference> > GetDirectProjectReferencesAsync(DependencyGraphCacheContext context)
 {
     return(Task.FromResult <IReadOnlyList <ProjectRestoreReference> >(
                Enumerable.Empty <ProjectRestoreReference>().ToList()));
 }