diff --git a/src/installer/pkg/projects/Microsoft.NETCore.App.Ref/Microsoft.NETCore.App.Ref.pkgproj b/src/installer/pkg/projects/Microsoft.NETCore.App.Ref/Microsoft.NETCore.App.Ref.pkgproj
index f61dce028e441325a9c613dc818e82ebc64d3a07..d53fc4377d6c83d719ceb91137e4a5d745158fc1 100644
--- a/src/installer/pkg/projects/Microsoft.NETCore.App.Ref/Microsoft.NETCore.App.Ref.pkgproj
+++ b/src/installer/pkg/projects/Microsoft.NETCore.App.Ref/Microsoft.NETCore.App.Ref.pkgproj
@@ -9,7 +9,8 @@
true
- data/
+ data/PlatformManifest.txt
+ data/
false
diff --git a/src/installer/pkg/projects/dir.props b/src/installer/pkg/projects/dir.props
index b240b5b527277baf321dd2c3f57f45967da2608f..723bca6c2c0b7ae75f53dc702bae769eed6f1661 100644
--- a/src/installer/pkg/projects/dir.props
+++ b/src/installer/pkg/projects/dir.props
@@ -20,6 +20,13 @@
true
+
+
+
+
+
+
+
true
true
diff --git a/src/installer/pkg/projects/dir.targets b/src/installer/pkg/projects/dir.targets
index 03da4f326c67c4e2cc0d210e92e310b59fa91c63..80333f3f73db482ec3f07925b31a1dfd86c2428b 100644
--- a/src/installer/pkg/projects/dir.targets
+++ b/src/installer/pkg/projects/dir.targets
@@ -1,6 +1,7 @@
+
@@ -180,4 +181,23 @@
+
+
+ $(IntermediateOutputPath)FrameworkList.xml
+
+
+
+
+
+
+ $(FrameworkListTargetPath)
+
+
+
+
\ No newline at end of file
diff --git a/tools-local/tasks/CreateFrameworkListFile.cs b/tools-local/tasks/CreateFrameworkListFile.cs
new file mode 100644
index 0000000000000000000000000000000000000000..37e5affb5d95b15cc6537040fa7cfe98ac19e3a9
--- /dev/null
+++ b/tools-local/tasks/CreateFrameworkListFile.cs
@@ -0,0 +1,82 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using Microsoft.Build.Framework;
+using System;
+using System.IO;
+using System.Linq;
+using System.Xml.Linq;
+
+namespace Microsoft.DotNet.Build.Tasks
+{
+ public class CreateFrameworkListFile : BuildTask
+ {
+ ///
+ /// Files to extract basic information from and include in the list.
+ ///
+ [Required]
+ public ITaskItem[] Files { get; set; }
+
+ [Required]
+ public string TargetFile { get; set; }
+
+ ///
+ /// Extra attributes to place on the root node.
+ ///
+ /// %(Identity): Attribute name.
+ /// %(Value): Attribute value.
+ ///
+ public ITaskItem[] RootAttributes { get; set; }
+
+ public override bool Execute()
+ {
+ XAttribute[] rootAttributes = RootAttributes
+ ?.Select(item => new XAttribute(item.ItemSpec, item.GetMetadata("Value")))
+ .ToArray();
+
+ var frameworkManifest = new XElement("FileList", rootAttributes);
+
+ foreach (var f in Files
+ .Where(item =>
+ item.GetMetadata("TargetPath")?.StartsWith("data/") == true &&
+ item.ItemSpec.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
+ .Select(item => new
+ {
+ Item = item,
+ AssemblyName = FileUtilities.GetAssemblyName(item.ItemSpec),
+ FileVersion = FileUtilities.GetFileVersion(item.ItemSpec)
+ })
+ .Where(f => f.AssemblyName != null)
+ .OrderBy(f => f.Item.ItemSpec, StringComparer.OrdinalIgnoreCase))
+ {
+ byte[] publicKeyToken = f.AssemblyName.GetPublicKeyToken();
+ string publicKeyTokenHex;
+
+ if (publicKeyToken != null)
+ {
+ publicKeyTokenHex = BitConverter.ToString(publicKeyToken)
+ .ToLowerInvariant()
+ .Replace("-", "");
+ }
+ else
+ {
+ Log.LogError($"No public key token found for assembly {f.Item.ItemSpec}");
+ publicKeyTokenHex = "";
+ }
+
+ frameworkManifest.Add(new XElement(
+ "File",
+ new XAttribute("AssemblyName", f.AssemblyName.Name),
+ new XAttribute("PublicKeyToken", publicKeyTokenHex),
+ new XAttribute("AssemblyVersion", f.AssemblyName.Version),
+ new XAttribute("FileVersion", f.FileVersion)));
+ }
+
+ Directory.CreateDirectory(Path.GetDirectoryName(TargetFile));
+ File.WriteAllText(TargetFile, frameworkManifest.ToString());
+
+ return !Log.HasLoggedErrors;
+ }
+ }
+}
diff --git a/tools-local/tasks/FileUtilities.cs b/tools-local/tasks/FileUtilities.cs
index e1f046130ad7f9b6fe20309d51f2b47578232467..40691aebbfb5b70f5b647747f93cf58c8637595e 100644
--- a/tools-local/tasks/FileUtilities.cs
+++ b/tools-local/tasks/FileUtilities.cs
@@ -10,8 +10,12 @@
namespace Microsoft.DotNet.Build.Tasks
{
- static partial class FileUtilities
+ internal static partial class FileUtilities
{
+ private static readonly HashSet s_assemblyExtensions = new HashSet(
+ new[] { ".dll", ".exe", ".winmd" },
+ StringComparer.OrdinalIgnoreCase);
+
public static Version GetFileVersion(string sourcePath)
{
var fvi = FileVersionInfo.GetVersionInfo(sourcePath);
@@ -24,21 +28,20 @@ public static Version GetFileVersion(string sourcePath)
return null;
}
- static readonly HashSet s_assemblyExtensions = new HashSet(new[] { ".dll", ".exe", ".winmd" }, StringComparer.OrdinalIgnoreCase);
- public static Version TryGetAssemblyVersion(string sourcePath)
+ public static AssemblyName GetAssemblyName(string path)
{
- var extension = Path.GetExtension(sourcePath);
+ if (!s_assemblyExtensions.Contains(Path.GetExtension(path)))
+ {
+ return null;
+ }
- return s_assemblyExtensions.Contains(extension) ? GetAssemblyVersion(sourcePath) : null;
- }
- private static Version GetAssemblyVersion(string sourcePath)
- {
try
{
- return AssemblyName.GetAssemblyName(sourcePath)?.Version;
+ return AssemblyName.GetAssemblyName(path);
}
catch (BadImageFormatException)
{
+ // Not a valid assembly.
return null;
}
}
diff --git a/tools-local/tasks/GenerateFileVersionProps.cs b/tools-local/tasks/GenerateFileVersionProps.cs
index 7e89cf6e73a8a0fac57ffdefc641596f9687d6f1..b306d4d3205a757efaa5934ec78af9fc09948521 100644
--- a/tools-local/tasks/GenerateFileVersionProps.cs
+++ b/tools-local/tasks/GenerateFileVersionProps.cs
@@ -131,7 +131,7 @@ FileVersionData GetFileVersionData(ITaskItem file)
{
return new FileVersionData()
{
- AssemblyVersion = FileUtilities.TryGetAssemblyVersion(filePath),
+ AssemblyVersion = FileUtilities.GetAssemblyName(filePath)?.Version,
FileVersion = FileUtilities.GetFileVersion(filePath)
};
}