diff --git a/src/OmniSharp.Script/ScriptProjectProvider.cs b/src/OmniSharp.Script/ScriptProjectProvider.cs index 6109b0d461..24436d0db9 100644 --- a/src/OmniSharp.Script/ScriptProjectProvider.cs +++ b/src/OmniSharp.Script/ScriptProjectProvider.cs @@ -98,10 +98,14 @@ private CSharpCompilationOptions CreateCompilationOptions() _logger.LogDebug($"CSX global using statement: {ns}"); } + var metadataReferenceResolver = CreateMetadataReferenceResolver(csharpCommandLineArguments?.ReferencePaths); + var sourceResolver = CreateScriptSourceResolver(csharpCommandLineArguments?.SourcePaths); + compilationOptions = compilationOptions .WithAllowUnsafe(true) - .WithMetadataReferenceResolver(CreateMetadataReferenceResolver()) - .WithSourceReferenceResolver(ScriptSourceResolver.Default) + + .WithMetadataReferenceResolver(metadataReferenceResolver) + .WithSourceReferenceResolver(sourceResolver) .WithAssemblyIdentityComparer(DesktopAssemblyIdentityComparer.Default) .WithSpecificDiagnosticOptions(!_scriptOptions.IsNugetEnabled() ? CompilationOptionsHelper.GetDefaultSuppressedDiagnosticOptions() @@ -125,9 +129,37 @@ private CSharpCompilationOptions CreateCompilationOptions() return compilationOptions; } - private CachingScriptMetadataResolver CreateMetadataReferenceResolver() + private ScriptSourceResolver CreateScriptSourceResolver(IEnumerable searchPaths) + { + var defaultResolver = ScriptSourceResolver.Default; + + if (searchPaths != null) + { + defaultResolver = defaultResolver.WithSearchPaths(searchPaths); + + foreach (string path in searchPaths) + { + _logger.LogInformation($"CSX source path: {path}."); + } + } + + return defaultResolver; + } + + private CachingScriptMetadataResolver CreateMetadataReferenceResolver(IEnumerable searchPaths) { var defaultResolver = ScriptMetadataResolver.Default.WithBaseDirectory(_env.TargetDirectory); + + if (searchPaths != null) + { + defaultResolver = defaultResolver.WithSearchPaths(searchPaths); + + foreach (string path in searchPaths) + { + _logger.LogInformation($"CSX reference path: {path}."); + } + } + InjectXMLDocumentationProviderIntoRuntimeMetadataReferenceResolver(defaultResolver); var decoratedResolver = _scriptOptions.EnableScriptNuGetReferences