From 70c60d176ccac7dad945656d3cae76b1aba50572 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Wed, 17 May 2023 22:13:22 -0700 Subject: [PATCH 1/3] Exclude System.* reference assemblies in ILCompiler.Build.Tasks We expect the implementation of these assemblies to come as part of msbuild. Fixes #83695 --- eng/Versions.props | 1 + .../aot/ILCompiler.Build.Tasks/ILCompiler.Build.Tasks.csproj | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/eng/Versions.props b/eng/Versions.props index 087c2c54ff5ea3..9c8a46fc227b1a 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -126,6 +126,7 @@ 7.0.0 5.0.0 4.5.5 + 4.5.0 7.0.0 6.0.0 5.0.0 diff --git a/src/coreclr/tools/aot/ILCompiler.Build.Tasks/ILCompiler.Build.Tasks.csproj b/src/coreclr/tools/aot/ILCompiler.Build.Tasks/ILCompiler.Build.Tasks.csproj index 69e06f3ddb0aa3..145655e9e61cfc 100644 --- a/src/coreclr/tools/aot/ILCompiler.Build.Tasks/ILCompiler.Build.Tasks.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Build.Tasks/ILCompiler.Build.Tasks.csproj @@ -16,6 +16,11 @@ + + + + + From 42b0e7043444fb4a5b807159f841e7efca55831c Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Thu, 18 May 2023 13:18:08 -0700 Subject: [PATCH 2/3] Do not include any System.* assemblies as part of the task --- eng/Versions.props | 1 - .../ILCompiler.Build.Tasks.csproj | 10 ++-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index 9c8a46fc227b1a..087c2c54ff5ea3 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -126,7 +126,6 @@ 7.0.0 5.0.0 4.5.5 - 4.5.0 7.0.0 6.0.0 5.0.0 diff --git a/src/coreclr/tools/aot/ILCompiler.Build.Tasks/ILCompiler.Build.Tasks.csproj b/src/coreclr/tools/aot/ILCompiler.Build.Tasks/ILCompiler.Build.Tasks.csproj index 145655e9e61cfc..742bc1b0f0be73 100644 --- a/src/coreclr/tools/aot/ILCompiler.Build.Tasks/ILCompiler.Build.Tasks.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Build.Tasks/ILCompiler.Build.Tasks.csproj @@ -9,18 +9,12 @@ $(RuntimeBinDir)/ilc-published/netstandard Debug;Release;Checked AnyCPU - true - - + + - - - - - From 7a471da319b0e3c51e98ef3c816dcbd62b59911a Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Thu, 18 May 2023 13:21:02 -0700 Subject: [PATCH 3/3] Delete custom resolver --- ...mputeManagedAssembliesToCompileToNative.cs | 2 +- .../DesktopCompatibleTask.cs | 98 ------------------- .../DumpNativeResources.cs | 3 +- 3 files changed, 3 insertions(+), 100 deletions(-) delete mode 100644 src/coreclr/tools/aot/ILCompiler.Build.Tasks/DesktopCompatibleTask.cs diff --git a/src/coreclr/tools/aot/ILCompiler.Build.Tasks/ComputeManagedAssembliesToCompileToNative.cs b/src/coreclr/tools/aot/ILCompiler.Build.Tasks/ComputeManagedAssembliesToCompileToNative.cs index 9a364cbc8a9646..ee68181bfd62b1 100644 --- a/src/coreclr/tools/aot/ILCompiler.Build.Tasks/ComputeManagedAssembliesToCompileToNative.cs +++ b/src/coreclr/tools/aot/ILCompiler.Build.Tasks/ComputeManagedAssembliesToCompileToNative.cs @@ -13,7 +13,7 @@ namespace Build.Tasks { - public class ComputeManagedAssembliesToCompileToNative : DesktopCompatibleTask + public class ComputeManagedAssembliesToCompileToNative : Task { [Required] public ITaskItem[] Assemblies diff --git a/src/coreclr/tools/aot/ILCompiler.Build.Tasks/DesktopCompatibleTask.cs b/src/coreclr/tools/aot/ILCompiler.Build.Tasks/DesktopCompatibleTask.cs deleted file mode 100644 index f17da926880fee..00000000000000 --- a/src/coreclr/tools/aot/ILCompiler.Build.Tasks/DesktopCompatibleTask.cs +++ /dev/null @@ -1,98 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Diagnostics; -using System.IO; -using System.Reflection; - -using Microsoft.Build.Utilities; - -namespace Build.Tasks -{ - public abstract class DesktopCompatibleTask : Task - { - static DesktopCompatibleTask() - { - AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; - } - - private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) - { - // apply any existing policy - AssemblyName referenceName = new AssemblyName(AppDomain.CurrentDomain.ApplyPolicy(args.Name)); - - string fileName = referenceName.Name + ".dll"; - string assemblyPath; - string probingPath; - Assembly assm; - - // look next to requesting assembly - assemblyPath = args.RequestingAssembly?.Location; - if (!string.IsNullOrEmpty(assemblyPath)) - { - probingPath = Path.Combine(Path.GetDirectoryName(assemblyPath), fileName); - Debug.WriteLine($"Considering {probingPath} based on RequestingAssembly"); - if (Probe(probingPath, referenceName.Version, out assm)) - { - return assm; - } - } - - // look next to the executing assembly - assemblyPath = Assembly.GetExecutingAssembly().Location; - if (!string.IsNullOrEmpty(assemblyPath)) - { - probingPath = Path.Combine(Path.GetDirectoryName(assemblyPath), fileName); - - Debug.WriteLine($"Considering {probingPath} based on ExecutingAssembly"); - if (Probe(probingPath, referenceName.Version, out assm)) - { - return assm; - } - } - - // look in AppDomain base directory - probingPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); - Debug.WriteLine($"Considering {probingPath} based on BaseDirectory"); - if (Probe(probingPath, referenceName.Version, out assm)) - { - return assm; - } - - // look in current directory - Debug.WriteLine($"Considering {fileName}"); - if (Probe(fileName, referenceName.Version, out assm)) - { - return assm; - } - - return null; - } - - /// - /// Considers a path to load for satisfying an assembly ref and loads it - /// if the file exists and version is sufficient. - /// - /// Path to consider for load - /// Minimum version to consider - /// loaded assembly - /// true if assembly was loaded - private static bool Probe(string filePath, Version minimumVersion, out Assembly assembly) - { - if (File.Exists(filePath)) - { - AssemblyName name = AssemblyName.GetAssemblyName(filePath); - - if (name.Version >= minimumVersion) - { - assembly = Assembly.Load(name); - return true; - } - } - - assembly = null; - return false; - } - } -} diff --git a/src/coreclr/tools/aot/ILCompiler.Build.Tasks/DumpNativeResources.cs b/src/coreclr/tools/aot/ILCompiler.Build.Tasks/DumpNativeResources.cs index d827d7b19618f8..374a9fd6137819 100644 --- a/src/coreclr/tools/aot/ILCompiler.Build.Tasks/DumpNativeResources.cs +++ b/src/coreclr/tools/aot/ILCompiler.Build.Tasks/DumpNativeResources.cs @@ -8,13 +8,14 @@ using System.Text; using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; namespace Build.Tasks { /// /// Dumps native Win32 resources in the given assembly into a specified *.res file. /// - public class DumpNativeResources : DesktopCompatibleTask + public class DumpNativeResources : Task { /// /// File name of the assembly with Win32 resources to be dumped.