@@ -852,7 +852,8 @@ private static AssemblyNameExtension GetAssemblyNameFromItemMetadata(ITaskItem i
852852 name = item . GetMetadata ( FileUtilities . ItemSpecModifiers . Filename ) ;
853853 }
854854
855- return new AssemblyNameExtension ( $ "{ name } , Version={ version } , Culture=neutral, PublicKeyToken={ publicKeyToken } ") ;
855+ AssemblyName assemblyName = new AssemblyName ( $ "{ name } , Version={ version } , Culture=neutral, PublicKeyToken={ publicKeyToken } ") ;
856+ return new AssemblyNameExtension ( assemblyName ) ;
856857 }
857858
858859 /// <summary>
@@ -2676,9 +2677,36 @@ private ITaskItem SetItemMetadata(List<ITaskItem> relatedItems, List<ITaskItem>
26762677 // Set up the main item.
26772678 TaskItem referenceItem = new TaskItem ( ) ;
26782679 referenceItem . ItemSpec = reference . FullPath ;
2680+ referenceItem . SetMetadata ( ItemMetadataNames . resolvedFrom , reference . ResolvedSearchPath ) ;
26792681
2680- IMetadataContainer referenceItemAsMetadataContainer = referenceItem ;
2681- referenceItemAsMetadataContainer . ImportMetadata ( EnumerateCommonMetadata ( ) ) ;
2682+ // Set the CopyLocal metadata.
2683+ referenceItem . SetMetadata ( ItemMetadataNames . copyLocal , reference . IsCopyLocal ? "true" : "false" ) ;
2684+
2685+ // Set the Redist name metadata.
2686+ if ( ! String . IsNullOrEmpty ( reference . RedistName ) )
2687+ {
2688+ referenceItem . SetMetadata ( ItemMetadataNames . redist , reference . RedistName ) ;
2689+ }
2690+
2691+ if ( Reference . IsFrameworkFile ( reference . FullPath , _frameworkPaths ) || ( _installedAssemblies ? . FrameworkAssemblyEntryInRedist ( assemblyName ) == true ) )
2692+ {
2693+ if ( ! IsAssemblyRemovedFromDotNetFramework ( assemblyName , reference . FullPath , _frameworkPaths , _installedAssemblies ) )
2694+ {
2695+ referenceItem . SetMetadata ( ItemMetadataNames . frameworkFile , "true" ) ;
2696+ }
2697+ }
2698+
2699+ if ( ! String . IsNullOrEmpty ( reference . ImageRuntime ) )
2700+ {
2701+ referenceItem . SetMetadata ( ItemMetadataNames . imageRuntime , reference . ImageRuntime ) ;
2702+ }
2703+
2704+ // The redist root is "null" when there was no IsRedistRoot flag in the Redist XML
2705+ // (or there was no redist XML at all for this item).
2706+ if ( reference . IsRedistRoot != null )
2707+ {
2708+ referenceItem . SetMetadata ( ItemMetadataNames . isRedistRoot , ( bool ) reference . IsRedistRoot ? "true" : "false" ) ;
2709+ }
26822710
26832711 // If there was a primary source item, then forward metadata from it.
26842712 // It's important that the metadata from the primary source item
@@ -2852,45 +2880,13 @@ private ITaskItem SetItemMetadata(List<ITaskItem> relatedItems, List<ITaskItem>
28522880 // nonForwardableMetadata should be null here if relatedFileExtensions, satellites, serializationAssemblyFiles, and scatterFiles were all empty.
28532881 if ( nonForwardableMetadata != null )
28542882 {
2855- referenceItemAsMetadataContainer . ImportMetadata ( nonForwardableMetadata ) ;
2856- }
2857-
2858- return referenceItem ;
2859-
2860- // Enumerate common metadata with an iterator to allow using a more efficient bulk-set operation.
2861- IEnumerable < KeyValuePair < string , string > > EnumerateCommonMetadata ( )
2862- {
2863- yield return new KeyValuePair < string , string > ( ItemMetadataNames . resolvedFrom , reference . ResolvedSearchPath ) ;
2864-
2865- // Set the CopyLocal metadata.
2866- yield return new KeyValuePair < string , string > ( ItemMetadataNames . copyLocal , reference . IsCopyLocal ? "true" : "false" ) ;
2867-
2868- // Set the Redist name metadata.
2869- if ( ! string . IsNullOrEmpty ( reference . RedistName ) )
2883+ foreach ( KeyValuePair < string , string > kvp in nonForwardableMetadata )
28702884 {
2871- yield return new KeyValuePair < string , string > ( ItemMetadataNames . redist , reference . RedistName ) ;
2872- }
2873-
2874- if ( Reference . IsFrameworkFile ( reference . FullPath , _frameworkPaths ) || ( _installedAssemblies ? . FrameworkAssemblyEntryInRedist ( assemblyName ) == true ) )
2875- {
2876- if ( ! IsAssemblyRemovedFromDotNetFramework ( assemblyName , reference . FullPath , _frameworkPaths , _installedAssemblies ) )
2877- {
2878- yield return new KeyValuePair < string , string > ( ItemMetadataNames . frameworkFile , "true" ) ;
2879- }
2880- }
2881-
2882- if ( ! string . IsNullOrEmpty ( reference . ImageRuntime ) )
2883- {
2884- yield return new KeyValuePair < string , string > ( ItemMetadataNames . imageRuntime , reference . ImageRuntime ) ;
2885- }
2886-
2887- // The redist root is "null" when there was no IsRedistRoot flag in the Redist XML
2888- // (or there was no redist XML at all for this item).
2889- if ( reference . IsRedistRoot != null )
2890- {
2891- yield return new KeyValuePair < string , string > ( ItemMetadataNames . isRedistRoot , ( bool ) reference . IsRedistRoot ? "true" : "false" ) ;
2885+ referenceItem . SetMetadata ( kvp . Key , kvp . Value ) ;
28922886 }
28932887 }
2888+
2889+ return referenceItem ;
28942890 }
28952891
28962892 /// <summary>
0 commit comments