/// <summary> /// Converts an immutable dictionary of rule snapshot data into an <see cref="IVsProjectRestoreInfo"/> instance. /// </summary> public static ProjectRestoreInfo ToProjectRestoreInfo(IImmutableDictionary <string, IProjectRuleSnapshot> update) { IImmutableDictionary <string, string> properties = update.GetSnapshotOrEmpty(NuGetRestore.SchemaName).Properties; IProjectRuleSnapshot frameworkReferences = update.GetSnapshotOrEmpty(CollectedFrameworkReference.SchemaName); IProjectRuleSnapshot packageDownloads = update.GetSnapshotOrEmpty(CollectedPackageDownload.SchemaName); IProjectRuleSnapshot projectReferences = update.GetSnapshotOrEmpty(ProjectReference.SchemaName); IProjectRuleSnapshot packageReferences = update.GetSnapshotOrEmpty(PackageReference.SchemaName); IProjectRuleSnapshot toolReferences = update.GetSnapshotOrEmpty(DotNetCliToolReference.SchemaName); // For certain project types such as UWP, "TargetFrameworkMoniker" != the moniker that restore uses string targetMoniker = properties.GetPropertyOrEmpty(NuGetRestore.NuGetTargetMonikerProperty); if (targetMoniker.Length == 0) { targetMoniker = properties.GetPropertyOrEmpty(NuGetRestore.TargetFrameworkMonikerProperty); } IVsTargetFrameworkInfo2 frameworkInfo = new TargetFrameworkInfo( targetMoniker, ToReferenceItems(frameworkReferences.Items), ToReferenceItems(packageDownloads.Items), ToReferenceItems(projectReferences.Items), ToReferenceItems(packageReferences.Items), ToProjectProperties(properties)); return(new ProjectRestoreInfo( properties.GetPropertyOrEmpty(NuGetRestore.MSBuildProjectExtensionsPathProperty), properties.GetPropertyOrEmpty(NuGetRestore.ProjectAssetsFileProperty), properties.GetPropertyOrEmpty(NuGetRestore.TargetFrameworksProperty), new TargetFrameworks(new[] { frameworkInfo }), ToReferenceItems(toolReferences.Items))); }
/// <summary> /// Converts an immutable dictionary of rule snapshot data into an <see cref="IVsProjectRestoreInfo"/> instance. /// </summary> public static IVsProjectRestoreInfo2 ToProjectRestoreInfo(IImmutableDictionary <string, IProjectRuleSnapshot> update) { Requires.NotNull(update, nameof(update)); IImmutableDictionary <string, string> properties = update.GetSnapshotOrEmpty(NuGetRestore.SchemaName).Properties; IProjectRuleSnapshot frameworkReferences = update.GetSnapshotOrEmpty(CollectedFrameworkReference.SchemaName); IProjectRuleSnapshot packageDownloads = update.GetSnapshotOrEmpty(CollectedPackageDownload.SchemaName); IProjectRuleSnapshot projectReferences = update.GetSnapshotOrEmpty(ProjectReference.SchemaName); IProjectRuleSnapshot packageReferences = update.GetSnapshotOrEmpty(PackageReference.SchemaName); IProjectRuleSnapshot toolReferences = update.GetSnapshotOrEmpty(DotNetCliToolReference.SchemaName); IVsTargetFrameworkInfo2 frameworkInfo = new TargetFrameworkInfo( properties.GetPropertyOrEmpty(NuGetRestore.TargetFrameworkMonikerProperty), ToReferenceItems(frameworkReferences.Items), ToReferenceItems(packageDownloads.Items), ToReferenceItems(projectReferences.Items), ToReferenceItems(packageReferences.Items), ToProjectProperties(properties)); return(new ProjectRestoreInfo( properties.GetPropertyOrEmpty(NuGetRestore.MSBuildProjectExtensionsPathProperty), properties.GetPropertyOrEmpty(NuGetRestore.TargetFrameworksProperty), new TargetFrameworks(new[] { frameworkInfo }), ToReferenceItems(toolReferences.Items))); }