Skip to content

Commit 026b064

Browse files
authored
library testhost modify deps.json to match actual release (#118864)
* modify deps.json to be more in line with actual release deps.json file
1 parent 95e0176 commit 026b064

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/tasks/installer.tasks/GenerateTestSharedFrameworkDepsFile.cs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,28 @@ public override bool Execute()
5050
".xml"
5151
};
5252

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 = [];
5655

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+
}
5975

6076
var runtimeLibraries = new[]
6177
{
@@ -64,8 +80,8 @@ public override bool Execute()
6480
name: sharedFxName,
6581
version: sharedFxVersion,
6682
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) },
6985
resourceAssemblies: Enumerable.Empty<ResourceAssembly>(),
7086
dependencies: Enumerable.Empty<Dependency>(),
7187
serviceable: true)
@@ -90,22 +106,6 @@ public override bool Execute()
90106
return !Log.HasLoggedErrors;
91107
}
92108

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-
109109
private static IEnumerable<RuntimeFallbacks> GetRuntimeFallbacks(string[] runtimeGraphFiles, string runtime)
110110
{
111111
RuntimeGraph runtimeGraph = RuntimeGraph.Empty;

0 commit comments

Comments
 (0)