diff --git a/src/coreclr/tools/aot/ILCompiler.Build.Tasks/ComputeManagedAssembliesToCompileToNative.cs b/src/coreclr/tools/aot/ILCompiler.Build.Tasks/ComputeManagedAssembliesToCompileToNative.cs index 9a364cbc8a964..ee68181bfd62b 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 f17da926880fe..0000000000000 --- 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 d827d7b19618f..374a9fd613781 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. 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 69e06f3ddb0aa..742bc1b0f0be7 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,12 +9,11 @@ $(RuntimeBinDir)/ilc-published/netstandard Debug;Release;Checked AnyCPU - true - - + +