From 524843fc9981352e062b676969b8f52373aaf666 Mon Sep 17 00:00:00 2001 From: filipw Date: Thu, 21 Nov 2019 09:52:03 +0100 Subject: [PATCH 1/3] do not override mono paths in standalone mode --- .../Providers/StandAloneInstanceProvider.cs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/OmniSharp.Host/MSBuild/Discovery/Providers/StandAloneInstanceProvider.cs b/src/OmniSharp.Host/MSBuild/Discovery/Providers/StandAloneInstanceProvider.cs index babddda9ef..decc5f11d6 100644 --- a/src/OmniSharp.Host/MSBuild/Discovery/Providers/StandAloneInstanceProvider.cs +++ b/src/OmniSharp.Host/MSBuild/Discovery/Providers/StandAloneInstanceProvider.cs @@ -38,22 +38,6 @@ public override ImmutableArray GetInstances() // a particular assembly in the GAC as a "guarantee". However, we don't include that // in our Mono package. So, we'll just bypass the check. propertyOverrides.Add("BypassFrameworkInstallChecks", "true"); - - // To better support older versions of Mono that don't include - // MSBuild 15, we attempt to set property overrides to the locations - // of Mono's 'xbuild' and 'xbuild-frameworks' paths. - if (_allowMonoPaths) - { - if (TryGetMonoXBuildPath(out var xbuildPath)) - { - extensionsPath = xbuildPath; - } - - if (TryGetMonoXBuildFrameworksPath(out var xbuildFrameworksPath)) - { - propertyOverrides.Add("TargetFrameworkRootPath", xbuildFrameworksPath); - } - } } propertyOverrides.Add("MSBuildToolsPath", toolsPath); From a34aeb40200182dfe33671335e0aec05577befe1 Mon Sep 17 00:00:00 2001 From: filipw Date: Fri, 22 Nov 2019 15:07:15 +0100 Subject: [PATCH 2/3] clean up constructors --- src/OmniSharp.Host/MSBuild/Discovery/MSBuildLocator.cs | 6 +++--- .../Discovery/Providers/StandAloneInstanceProvider.cs | 5 +---- tests/OmniSharp.MSBuild.Tests/AbstractMSBuildTestFixture.cs | 2 +- tests/TestUtility/TestServiceProvider.cs | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/OmniSharp.Host/MSBuild/Discovery/MSBuildLocator.cs b/src/OmniSharp.Host/MSBuild/Discovery/MSBuildLocator.cs index 0abbf7a4a9..872a17758d 100644 --- a/src/OmniSharp.Host/MSBuild/Discovery/MSBuildLocator.cs +++ b/src/OmniSharp.Host/MSBuild/Discovery/MSBuildLocator.cs @@ -47,13 +47,13 @@ public static MSBuildLocator CreateDefault(ILoggerFactory loggerFactory, IAssemb new DevConsoleInstanceProvider(loggerFactory), new VisualStudioInstanceProvider(loggerFactory), new MonoInstanceProvider(loggerFactory), - new StandAloneInstanceProvider(loggerFactory, allowMonoPaths: true), + new StandAloneInstanceProvider(loggerFactory), new UserOverrideInstanceProvider(loggerFactory, msbuildConfiguration))); - public static MSBuildLocator CreateStandAlone(ILoggerFactory loggerFactory, IAssemblyLoader assemblyLoader, bool allowMonoPaths) + public static MSBuildLocator CreateStandAlone(ILoggerFactory loggerFactory, IAssemblyLoader assemblyLoader) => new MSBuildLocator(loggerFactory, assemblyLoader, ImmutableArray.Create( - new StandAloneInstanceProvider(loggerFactory, allowMonoPaths))); + new StandAloneInstanceProvider(loggerFactory))); public void RegisterInstance(MSBuildInstance instance) { diff --git a/src/OmniSharp.Host/MSBuild/Discovery/Providers/StandAloneInstanceProvider.cs b/src/OmniSharp.Host/MSBuild/Discovery/Providers/StandAloneInstanceProvider.cs index decc5f11d6..bac81905f1 100644 --- a/src/OmniSharp.Host/MSBuild/Discovery/Providers/StandAloneInstanceProvider.cs +++ b/src/OmniSharp.Host/MSBuild/Discovery/Providers/StandAloneInstanceProvider.cs @@ -8,12 +8,9 @@ namespace OmniSharp.MSBuild.Discovery.Providers { internal class StandAloneInstanceProvider : MSBuildInstanceProvider { - private readonly bool _allowMonoPaths; - - public StandAloneInstanceProvider(ILoggerFactory loggerFactory, bool allowMonoPaths) + public StandAloneInstanceProvider(ILoggerFactory loggerFactory) : base(loggerFactory) { - _allowMonoPaths = allowMonoPaths; } public override ImmutableArray GetInstances() diff --git a/tests/OmniSharp.MSBuild.Tests/AbstractMSBuildTestFixture.cs b/tests/OmniSharp.MSBuild.Tests/AbstractMSBuildTestFixture.cs index 6f9e81797c..cbc1858271 100644 --- a/tests/OmniSharp.MSBuild.Tests/AbstractMSBuildTestFixture.cs +++ b/tests/OmniSharp.MSBuild.Tests/AbstractMSBuildTestFixture.cs @@ -22,7 +22,7 @@ public AbstractMSBuildTestFixture(ITestOutputHelper output) { _assemblyLoader = new AssemblyLoader(this.LoggerFactory); _analyzerAssemblyLoader = new AnalyzerAssemblyLoader(); - _msbuildLocator = MSBuildLocator.CreateStandAlone(this.LoggerFactory, _assemblyLoader, allowMonoPaths: false); + _msbuildLocator = MSBuildLocator.CreateStandAlone(this.LoggerFactory, _assemblyLoader); // Some tests require MSBuild to be discovered early // to ensure that the Microsoft.Build.* assemblies can be located diff --git a/tests/TestUtility/TestServiceProvider.cs b/tests/TestUtility/TestServiceProvider.cs index 559621d73e..19c44de071 100644 --- a/tests/TestUtility/TestServiceProvider.cs +++ b/tests/TestUtility/TestServiceProvider.cs @@ -155,7 +155,7 @@ private static IMemoryCache CreateMemoryCache() => new MemoryCache(new MemoryCacheOptions()); private static IMSBuildLocator CreateMSBuildLocator(ILoggerFactory loggerFactory, IAssemblyLoader assemblyLoader) - => MSBuildLocator.CreateStandAlone(loggerFactory, assemblyLoader, allowMonoPaths: false); + => MSBuildLocator.CreateStandAlone(loggerFactory, assemblyLoader); private static IOptionsMonitor CreateOptionsMonitor(IConfigurationRoot configurationRoot) { From 635a048adc4e915ebf1aaa7c2d40cacccd4722f8 Mon Sep 17 00:00:00 2001 From: filipw Date: Fri, 22 Nov 2019 15:10:21 +0100 Subject: [PATCH 3/3] removed unused code --- .../Providers/StandAloneInstanceProvider.cs | 42 ------------------- 1 file changed, 42 deletions(-) diff --git a/src/OmniSharp.Host/MSBuild/Discovery/Providers/StandAloneInstanceProvider.cs b/src/OmniSharp.Host/MSBuild/Discovery/Providers/StandAloneInstanceProvider.cs index bac81905f1..20c8d374f0 100644 --- a/src/OmniSharp.Host/MSBuild/Discovery/Providers/StandAloneInstanceProvider.cs +++ b/src/OmniSharp.Host/MSBuild/Discovery/Providers/StandAloneInstanceProvider.cs @@ -51,47 +51,5 @@ public override ImmutableArray GetInstances() propertyOverrides.ToImmutable(), setMSBuildExePathVariable: true)); } - - private static bool TryGetMonoXBuildPath(out string path) - { - path = null; - - var monoXBuildDirPath = PlatformHelper.GetMonoXBuildDirPath(); - if (monoXBuildDirPath == null) - { - return false; - } - - var monoXBuild15DirPath = Path.Combine(monoXBuildDirPath, "15.0"); - if (Directory.Exists(monoXBuild15DirPath)) - { - path = monoXBuildDirPath; - return true; - } - - - var monoXBuildCurrentDirPath = Path.Combine(monoXBuildDirPath, "Current"); - if (Directory.Exists(monoXBuildCurrentDirPath)) - { - path = monoXBuildDirPath; - return true; - } - - return false; - } - - private static bool TryGetMonoXBuildFrameworksPath(out string path) - { - path = null; - - var monoMSBuildXBuildFrameworksDirPath = PlatformHelper.GetMonoXBuildFrameworksDirPath(); - if (monoMSBuildXBuildFrameworksDirPath == null) - { - return false; - } - - path = monoMSBuildXBuildFrameworksDirPath; - return true; - } } }