@@ -50,12 +50,28 @@ public override bool Execute()
50
50
".xml"
51
51
} ;
52
52
53
- var isAssemblyTofileNames = Directory . EnumerateFiles ( SharedFrameworkDirectory )
54
- . Where ( file => ! ignoredExtensions . Contains ( Path . GetExtension ( file ) ) )
55
- . ToLookup ( file => IsManagedAssembly ( file ) , file => Path . GetFileName ( file ) ) ;
53
+ List < RuntimeFile > runtimeFiles = [ ] ;
54
+ List < RuntimeFile > nativeFiles = [ ] ;
56
55
57
- var managedFileNames = isAssemblyTofileNames [ true ] ;
58
- var nativeFileNames = isAssemblyTofileNames [ false ] ;
56
+ foreach ( string filePath in Directory . EnumerateFiles ( SharedFrameworkDirectory ) )
57
+ {
58
+ if ( ignoredExtensions . Contains ( Path . GetExtension ( filePath ) ) )
59
+ continue ;
60
+
61
+ string fileName = Path . GetFileName ( filePath ) ;
62
+ string fileVersion = FileUtilities . GetFileVersion ( filePath ) ? . ToString ( ) ?? string . Empty ;
63
+ Version assemblyVersion = FileUtilities . GetAssemblyName ( filePath ) ? . Version ;
64
+ if ( assemblyVersion is null )
65
+ {
66
+ RuntimeFile nativeFile = new RuntimeFile ( fileName , null , fileVersion ) ;
67
+ nativeFiles . Add ( nativeFile ) ;
68
+ }
69
+ else
70
+ {
71
+ RuntimeFile runtimeFile = new RuntimeFile ( fileName , assemblyVersion . ToString ( ) , fileVersion ) ;
72
+ runtimeFiles . Add ( runtimeFile ) ;
73
+ }
74
+ }
59
75
60
76
var runtimeLibraries = new [ ]
61
77
{
@@ -64,8 +80,8 @@ public override bool Execute()
64
80
name : sharedFxName ,
65
81
version : sharedFxVersion ,
66
82
hash : "hash" ,
67
- runtimeAssemblyGroups : new [ ] { new RuntimeAssetGroup ( string . Empty , managedFileNames . Select ( f => $ "runtimes/ { rid } /lib/ { tfm } / { f } " ) ) } ,
68
- nativeLibraryGroups : new [ ] { new RuntimeAssetGroup ( string . Empty , nativeFileNames . Select ( f => $ "runtimes/ { rid } /native/ { f } " ) ) } ,
83
+ runtimeAssemblyGroups : new [ ] { new RuntimeAssetGroup ( string . Empty , runtimeFiles ) } ,
84
+ nativeLibraryGroups : new [ ] { new RuntimeAssetGroup ( string . Empty , nativeFiles ) } ,
69
85
resourceAssemblies : Enumerable . Empty < ResourceAssembly > ( ) ,
70
86
dependencies : Enumerable . Empty < Dependency > ( ) ,
71
87
serviceable : true )
@@ -90,22 +106,6 @@ public override bool Execute()
90
106
return ! Log . HasLoggedErrors ;
91
107
}
92
108
93
- private static bool IsManagedAssembly ( string file )
94
- {
95
- bool result = false ;
96
- try
97
- {
98
- using ( var peReader = new PEReader ( File . OpenRead ( file ) ) )
99
- {
100
- result = peReader . HasMetadata && peReader . GetMetadataReader ( ) . IsAssembly ;
101
- }
102
- }
103
- catch ( BadImageFormatException )
104
- { }
105
-
106
- return result ;
107
- }
108
-
109
109
private static IEnumerable < RuntimeFallbacks > GetRuntimeFallbacks ( string [ ] runtimeGraphFiles , string runtime )
110
110
{
111
111
RuntimeGraph runtimeGraph = RuntimeGraph . Empty ;
0 commit comments