public static LockFileTargetLibrary CreateLockFileTargetLibrary(Runtime.Project projectDependency, RestoreContext context) { var targetFrameworkInfo = projectDependency.GetCompatibleTargetFramework(context.FrameworkName); var lockFileLib = new LockFileTargetLibrary { Name = projectDependency.Name, Version = projectDependency.Version, TargetFramework = targetFrameworkInfo.FrameworkName, // null TFM means it's incompatible Type = "project" }; var dependencies = projectDependency.Dependencies.Concat(targetFrameworkInfo.Dependencies); foreach (var dependency in dependencies) { if (dependency.LibraryRange.IsGacOrFrameworkReference) { lockFileLib.FrameworkAssemblies.Add( LibraryRange.GetAssemblyName(dependency.LibraryRange.Name)); } else { lockFileLib.Dependencies.Add(new PackageDependency( dependency.LibraryRange.Name, dependency.LibraryRange.VersionRange)); } } return lockFileLib; }
private IEnumerable<FrameworkName> SelectCompatibleFrameworks(PublishRoot root, Runtime.Project project, IEnumerable<FrameworkName> requestedFrameworks) { var selectedFrameworks = new List<FrameworkName>(); foreach (var framework in requestedFrameworks) { var selectedFramework = project.GetCompatibleTargetFramework(framework); if (selectedFramework == null) { root.Reports.WriteError($"Unable to build {project.Name}. It is not compatible with the requested target framework: {framework}"); return null; } selectedFrameworks.Add(selectedFramework.FrameworkName); } return selectedFrameworks; }