Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not set mono paths in standalone mode #1656

Merged
merged 3 commits into from
Nov 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/OmniSharp.Host/MSBuild/Discovery/MSBuildLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MSBuildInstanceProvider>(
new StandAloneInstanceProvider(loggerFactory, allowMonoPaths)));
new StandAloneInstanceProvider(loggerFactory)));

public void RegisterInstance(MSBuildInstance instance)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<MSBuildInstance> GetInstances()
Expand All @@ -38,22 +35,6 @@ public override ImmutableArray<MSBuildInstance> 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);
Expand All @@ -70,47 +51,5 @@ public override ImmutableArray<MSBuildInstance> 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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/TestUtility/TestServiceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<OmniSharpOptions> CreateOptionsMonitor(IConfigurationRoot configurationRoot)
{
Expand Down