From c4a411da48af21d9b6bce281956fdac32f256175 Mon Sep 17 00:00:00 2001 From: Jason Malinowski Date: Wed, 30 Aug 2023 14:03:30 -0700 Subject: [PATCH] We don't have to hook assembly load now that we're not using MEF --- .../Core/MSBuild.BuildHost/Program.cs | 29 ++----------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/src/Workspaces/Core/MSBuild.BuildHost/Program.cs b/src/Workspaces/Core/MSBuild.BuildHost/Program.cs index 593d3d5f5a11d..e31732f6194b6 100644 --- a/src/Workspaces/Core/MSBuild.BuildHost/Program.cs +++ b/src/Workspaces/Core/MSBuild.BuildHost/Program.cs @@ -3,16 +3,10 @@ // See the LICENSE file in the project root for more information. using System; -using System.IO; -using System.Reflection; -using System.Threading.Tasks; -using StreamJsonRpc; using System.CommandLine; +using System.Threading.Tasks; using Microsoft.Extensions.Logging; - -#if NETCOREAPP -using System.Runtime.Loader; -#endif +using StreamJsonRpc; namespace Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost; @@ -35,25 +29,6 @@ internal static async Task Main(string[] args) var logger = loggerFactory.CreateLogger(typeof(Program)); -#if NETCOREAPP - - // In the .NET Core case, the dependencies we want to dynamically load are not in our deps.json file, so we won't find them when MefHostServices tries to load them - // with Assembly.Load. To work around this, we'll use LoadFrom instead by hooking our AssemblyLoadContext Resolving. - var thisAssemblyDirectory = Path.GetDirectoryName(typeof(Program).Assembly.Location)!; - AssemblyLoadContext.Default.Resolving += (context, assemblyName) => - { - try - { - return Assembly.LoadFrom(Path.Combine(thisAssemblyDirectory, assemblyName.Name! + ".dll")); - } - catch (Exception) - { - return null; - } - }; - -#endif - var messageHandler = new HeaderDelimitedMessageHandler(sendingStream: Console.OpenStandardOutput(), receivingStream: Console.OpenStandardInput(), new JsonMessageFormatter()); var jsonRpc = new JsonRpc(messageHandler)