Require 1:1 WindowsDesktop Profile classification (dotnet/core-setup#6698)
authorDavis Goodin <dagood@users.noreply.github.com>
Thu, 6 Jun 2019 16:35:32 +0000 (11:35 -0500)
committerGitHub <noreply@github.com>
Thu, 6 Jun 2019 16:35:32 +0000 (11:35 -0500)
Commit migrated from https://github.com/dotnet/core-setup/commit/90a101062a687dc1ac02e02d18c3356feb5e9a09

src/installer/pkg/projects/windowsdesktop/pkg/dir.props
tools-local/tasks/CreateFrameworkListFile.cs

index e1f5597..08ecb3e 100644 (file)
 
   <ItemGroup Condition="'$(PackageTargetRuntime)' == ''">
     <FrameworkListFileProfile Include="Accessibility.dll" Profile="WindowsForms;WPF" />
-    <FrameworkListFileProfile Include="D3DCompiler_47_cor3.dll" Profile="WPF" />
-    <FrameworkListFileProfile Include="DirectWriteForwarder.dll" Profile="WPF" />
     <FrameworkListFileProfile Include="Microsoft.Win32.Registry.dll" Profile="WindowsForms;WPF" />
     <FrameworkListFileProfile Include="Microsoft.Win32.SystemEvents.dll" Profile="WindowsForms;WPF" />
-    <FrameworkListFileProfile Include="PenImc_cor3.dll" Profile="WPF" />
-    <FrameworkListFileProfile Include="PresentationCore-CommonResources.dll" Profile="WPF" />
     <FrameworkListFileProfile Include="PresentationCore.dll" Profile="WPF" />
     <FrameworkListFileProfile Include="PresentationFramework-SystemCore.dll" Profile="WPF" />
     <FrameworkListFileProfile Include="PresentationFramework-SystemData.dll" Profile="WPF" />
     <FrameworkListFileProfile Include="PresentationFramework.dll" Profile="WPF" />
     <FrameworkListFileProfile Include="PresentationFramework.Luna.dll" Profile="WPF" />
     <FrameworkListFileProfile Include="PresentationFramework.Royale.dll" Profile="WPF" />
-    <FrameworkListFileProfile Include="PresentationNative_cor3.dll" Profile="WPF" />
     <FrameworkListFileProfile Include="PresentationUI.dll" Profile="WPF" />
     <FrameworkListFileProfile Include="ReachFramework.dll" Profile="WPF" />
     <FrameworkListFileProfile Include="System.CodeDom.dll" Profile="WindowsForms;WPF" />
     <FrameworkListFileProfile Include="System.Configuration.ConfigurationManager.dll" Profile="WindowsForms;WPF" />
     <FrameworkListFileProfile Include="System.Design.dll" Profile="WindowsForms" />
-    <FrameworkListFileProfile Include="System.Diagnostics.EventLog.dll" Profile="WindowsForms;WPF" />
-    <FrameworkListFileProfile Include="System.DirectoryServices.dll" Profile="WindowsForms;WPF" />
     <FrameworkListFileProfile Include="System.Drawing.Common.dll" Profile="WindowsForms" />
     <FrameworkListFileProfile Include="System.Drawing.Design.dll" Profile="WindowsForms" />
-    <FrameworkListFileProfile Include="System.Drawing.Design.Primitives.dll" Profile="WindowsForms" />
     <FrameworkListFileProfile Include="System.Drawing.dll" Profile="WindowsForms" />
-    <FrameworkListFileProfile Include="System.IO.FileSystem.AccessControl.dll" Profile="WindowsForms;WPF" />
     <FrameworkListFileProfile Include="System.IO.Packaging.dll" Profile="WindowsForms;WPF" />
-    <FrameworkListFileProfile Include="System.Media.SoundPlayer.dll" Profile="WindowsForms;WPF" />
     <FrameworkListFileProfile Include="System.Printing.dll" Profile="WPF" />
     <FrameworkListFileProfile Include="System.Resources.Extensions.dll" Profile="WindowsForms;WPF" />
     <FrameworkListFileProfile Include="System.Security.AccessControl.dll" Profile="WindowsForms;WPF" />
@@ -66,7 +56,6 @@
     <FrameworkListFileProfile Include="System.Security.Cryptography.Xml.dll" Profile="WindowsForms;WPF" />
     <FrameworkListFileProfile Include="System.Security.Permissions.dll" Profile="WindowsForms;WPF" />
     <FrameworkListFileProfile Include="System.Security.Principal.Windows.dll" Profile="WindowsForms;WPF" />
-    <FrameworkListFileProfile Include="System.Threading.AccessControl.dll" Profile="WindowsForms;WPF" />
     <FrameworkListFileProfile Include="System.Windows.Controls.Ribbon.dll" Profile="WPF" />
     <FrameworkListFileProfile Include="System.Windows.Extensions.dll" Profile="WindowsForms;WPF" />
     <FrameworkListFileProfile Include="System.Windows.Forms.Design.dll" Profile="WindowsForms" />
     <FrameworkListFileProfile Include="UIAutomationClientSideProviders.dll" Profile="WPF" />
     <FrameworkListFileProfile Include="UIAutomationProvider.dll" Profile="WPF" />
     <FrameworkListFileProfile Include="UIAutomationTypes.dll" Profile="WPF" />
-    <FrameworkListFileProfile Include="vcruntime140_cor3.dll" Profile="WPF" />
     <FrameworkListFileProfile Include="WindowsBase.dll" Profile="WPF" />
-    <FrameworkListFileProfile Include="WPFgfx_cor3.dll" Profile="WPF" />
-
-    <!-- If any of these files has resource dlls, use the file's profile. -->
-    <FrameworkListFileProfile Include="@(FrameworkListFileProfile -> '%(Filename).resources%(Extension)')" />
+    <FrameworkListFileProfile Include="WindowsFormsIntegration.dll" />
   </ItemGroup>
 
   <!-- Redistribute package content from other nuget packages. -->
index 3bc75c9..3d1d539 100644 (file)
@@ -20,9 +20,19 @@ namespace Microsoft.DotNet.Build.Tasks
         public ITaskItem[] Files { get; set; }
 
         /// <summary>
-        /// A list of assembly names to add Profile="%(Profile)" attributes to, if the assembly
-        /// names exist in Files.
-        /// 
+        /// A list of assembly names with Profile classifications. A Profile="%(Profile)" attribute
+        /// is set in the framework list for the matching Files item if %(Profile) contains text.
+        ///
+        /// If *any* FileProfiles are passed:
+        ///
+        ///   *Every* file that ends up listed in the framework list must have a matching
+        ///   FileProfile, even if %(Profile) is not set.
+        ///
+        ///   Additionally, every FileProfile must find exactly one File.
+        ///
+        /// This task fails if the conditions aren't met. This ensures the classification doesn't
+        /// become out of date when the list of files changes.
+        ///
         /// %(Identity): Assembly name (including ".dll").
         /// %(Profile): List of profiles that apply, semicolon-delimited.
         /// </summary>
@@ -49,12 +59,14 @@ namespace Microsoft.DotNet.Build.Tasks
 
             var frameworkManifest = new XElement("FileList", rootAttributes);
 
-            Dictionary<string, string> fileProfileLookup = (FileProfiles ?? Array.Empty<ITaskItem>())
-                .ToDictionary(
+            Dictionary<string, string> fileProfileLookup = FileProfiles
+                ?.ToDictionary(
                     item => item.ItemSpec,
                     item => item.GetMetadata("Profile"),
                     StringComparer.OrdinalIgnoreCase);
 
+            var usedFileProfiles = new HashSet<string>();
+
             foreach (var f in Files
                 .Where(IsTargetPathIncluded)
                 .Select(item => new
@@ -110,14 +122,33 @@ namespace Microsoft.DotNet.Build.Tasks
 
                 element.Add(new XAttribute("FileVersion", f.FileVersion));
 
-                if (fileProfileLookup.TryGetValue(f.Filename, out string profile))
+                if (fileProfileLookup != null)
                 {
-                    element.Add(new XAttribute("Profile", profile));
+                    if (fileProfileLookup.TryGetValue(f.Filename, out string profile))
+                    {
+                        if (!string.IsNullOrEmpty(profile))
+                        {
+                            element.Add(new XAttribute("Profile", profile));
+                        }
+
+                        usedFileProfiles.Add(f.Filename);
+                    }
+                    else
+                    {
+                        Log.LogError($"File matches no profile classification: {f.Filename}");
+                    }
                 }
 
                 frameworkManifest.Add(element);
             }
 
+            foreach (var unused in fileProfileLookup
+                ?.Keys.Except(usedFileProfiles).OrderBy(p => p)
+                ?? Enumerable.Empty<string>())
+            {
+                Log.LogError($"Profile classification matches no files: {unused}");
+            }
+
             Directory.CreateDirectory(Path.GetDirectoryName(TargetFile));
             File.WriteAllText(TargetFile, frameworkManifest.ToString());