Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions src/tasks/installer.tasks/GenerateTestSharedFrameworkDepsFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,28 @@ public override bool Execute()
".xml"
};

var isAssemblyTofileNames = Directory.EnumerateFiles(SharedFrameworkDirectory)
.Where(file => !ignoredExtensions.Contains(Path.GetExtension(file)))
.ToLookup(file => IsManagedAssembly(file), file => Path.GetFileName(file));
List<RuntimeFile> runtimeFiles = [];
List<RuntimeFile> nativeFiles = [];

var managedFileNames = isAssemblyTofileNames[true];
var nativeFileNames = isAssemblyTofileNames[false];
foreach (string filePath in Directory.EnumerateFiles(SharedFrameworkDirectory))
{
if (ignoredExtensions.Contains(Path.GetExtension(filePath)))
continue;

string fileName = Path.GetFileName(filePath);
string fileVersion = FileUtilities.GetFileVersion(filePath)?.ToString() ?? string.Empty;
Version assemblyVersion = FileUtilities.GetAssemblyName(filePath)?.Version;
if (assemblyVersion is null)
{
RuntimeFile nativeFile = new RuntimeFile(fileName, null, fileVersion);
nativeFiles.Add(nativeFile);
}
else
{
RuntimeFile runtimeFile = new RuntimeFile(fileName, assemblyVersion.ToString(), fileVersion);
runtimeFiles.Add(runtimeFile);
}
}

var runtimeLibraries = new[]
{
Expand All @@ -64,8 +80,8 @@ public override bool Execute()
name: sharedFxName,
version: sharedFxVersion,
hash: "hash",
runtimeAssemblyGroups: new[] { new RuntimeAssetGroup(string.Empty, managedFileNames.Select(f => $"runtimes/{rid}/lib/{tfm}/{f}")) },
nativeLibraryGroups: new[] { new RuntimeAssetGroup(string.Empty, nativeFileNames.Select(f => $"runtimes/{rid}/native/{f}")) },
runtimeAssemblyGroups: new[] { new RuntimeAssetGroup(string.Empty, runtimeFiles) },
nativeLibraryGroups: new[] { new RuntimeAssetGroup(string.Empty, nativeFiles) },
resourceAssemblies: Enumerable.Empty<ResourceAssembly>(),
dependencies: Enumerable.Empty<Dependency>(),
serviceable: true)
Expand All @@ -90,22 +106,6 @@ public override bool Execute()
return !Log.HasLoggedErrors;
}

private static bool IsManagedAssembly(string file)
{
bool result = false;
try
{
using (var peReader = new PEReader(File.OpenRead(file)))
{
result = peReader.HasMetadata && peReader.GetMetadataReader().IsAssembly;
}
}
catch (BadImageFormatException)
{ }

return result;
}

private static IEnumerable<RuntimeFallbacks> GetRuntimeFallbacks(string[] runtimeGraphFiles, string runtime)
{
RuntimeGraph runtimeGraph = RuntimeGraph.Empty;
Expand Down
Loading