Remove hardcoded non trimmable assemblies in oob.proj (#72171)
authorViktor Hofer <viktor.hofer@microsoft.com>
Thu, 14 Jul 2022 23:03:46 +0000 (01:03 +0200)
committerGitHub <noreply@github.com>
Thu, 14 Jul 2022 23:03:46 +0000 (01:03 +0200)
* Remove hardcoded non trimmable assemblies in oob.proj

Fixes https://github.com/dotnet/runtime/issues/72166

Use the `TargetPathWithTargetPlatformMoniker` to flow through the IsTrimmable property that is set by projects and use that for illink validation assembly selection.

* Update oob.proj

* Update illink.targets

eng/illink.targets
src/libraries/oob.proj

index 33d7dd9..44fbe03 100644 (file)
@@ -6,6 +6,14 @@
     <!-- ApiCompat should perform compatibility checks on the trimmed assemblies. -->
     <ApiCompatDependsOn>$(ApiCompatDependsOn);ILLinkTrimAssembly</ApiCompatDependsOn>
   </PropertyGroup>
+  
+  <!-- Flow the IsTrimmable property down to consuming projects, in order for oob.proj
+       to exclude non trimmable assemblies. -->
+  <ItemDefinitionGroup>
+    <TargetPathWithTargetPlatformMoniker>
+      <IsTrimmable>$(IsTrimmable)</IsTrimmable>
+    </TargetPathWithTargetPlatformMoniker>
+  </ItemDefinitionGroup>
 
   <!-- Inputs and outputs of ILLinkTrimAssembly -->
   <PropertyGroup>
index 74a8bfb..cc910f2 100644 (file)
       <!-- Include suppression XML files bin-placed in earlier per-library linker run. -->
       <OOBLibrarySuppressionsXml Include="$(ILLinkTrimAssemblyOOBSuppressionsXmlsDir)*.xml" />
       
-      <!-- The following is the list of all the OOBs we will ignore for now -->
-      <OOBAssemblyToIgnore Include="System.CodeDom;
-                                    System.ComponentModel.Composition;
-                                    System.ComponentModel.Composition.Registration;
-                                    System.Composition.AttributedModel;
-                                    System.Composition.Convention;
-                                    System.Composition.Hosting;
-                                    System.Composition.Runtime;
-                                    System.Composition.TypedParts;
-                                    System.Configuration.ConfigurationManager;
-                                    System.Speech;
-                                    Microsoft.Extensions.DependencyInjection.Specification.Tests" />
-
-      <!-- Move items to FileName so that we can subtract them. -->
-      <OOBAssemblyWithFilename Include="@(OOBAssembly->Metadata('Filename'))"
-                               OriginalIdentity="%(Identity)" />
-      <OOBAssemblyToTrimWithFilename Include="@(OOBAssemblyWithFilename)"
-                                     Exclude="@(OOBAssemblyToIgnore)" />
-      <OOBAssemblyToIgnoreWithFilename Include="@(OOBAssemblyWithFilename)"
-                                       Exclude="@(OOBAssemblyToTrimWithFilename)" />
-
-      <OOBAssemblyToTrim Include="@(OOBAssemblyToTrimWithFilename->Metadata('OriginalIdentity'))" />
-      <OOBAssemblyReference Include="@(OOBAssemblyToIgnoreWithFilename->Metadata('OriginalIdentity'));
+      <OOBAssemblyToTrim Include="@(OOBAssembly->WithMetadataValue('IsTrimmable', 'true'))" />
+      <OOBAssemblyReference Include="@(OOBAssembly->WithMetadataValue('IsTrimmable', 'false'));
                                      @(SharedFrameworkAssembly)" />
     </ItemGroup>
   </Target>