From d5607317b9adc03ebae978a0b5aea81427a4de1e Mon Sep 17 00:00:00 2001 From: ByronMayne Date: Sun, 8 Nov 2020 10:28:53 -0500 Subject: [PATCH] Response File Path can now use ENV Vars Added more error handling to help users know what is going wrong. --- src/OmniSharp.Script/ScriptOptions.cs | 9 ++++++--- src/OmniSharp.Script/ScriptProjectProvider.cs | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/OmniSharp.Script/ScriptOptions.cs b/src/OmniSharp.Script/ScriptOptions.cs index cd9e052e89..03abfe5ce9 100644 --- a/src/OmniSharp.Script/ScriptOptions.cs +++ b/src/OmniSharp.Script/ScriptOptions.cs @@ -41,9 +41,12 @@ public bool IsNugetEnabled() => public string GetNormalizedRspFilePath(IOmniSharpEnvironment env) { if (string.IsNullOrWhiteSpace(RspFilePath)) return null; - return Path.IsPathRooted(RspFilePath) - ? RspFilePath - : Path.Combine(env.TargetDirectory, RspFilePath); + + var expandedPath = Environment.ExpandEnvironmentVariables(RspFilePath); + + return Path.IsPathRooted(expandedPath) + ? expandedPath + : Path.Combine(env.TargetDirectory, expandedPath); } public Dictionary NullableDiagnostics => _nullableDiagnostics.Value; diff --git a/src/OmniSharp.Script/ScriptProjectProvider.cs b/src/OmniSharp.Script/ScriptProjectProvider.cs index 24436d0db9..9ebb06e767 100644 --- a/src/OmniSharp.Script/ScriptProjectProvider.cs +++ b/src/OmniSharp.Script/ScriptProjectProvider.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.IO; @@ -72,6 +72,12 @@ private CSharpCommandLineArguments CreateCommandLineArguments() var rspFilePath = _scriptOptions.GetNormalizedRspFilePath(_env); if (rspFilePath != null) { + if(!File.Exists(rspFilePath)) + { + _logger.LogError($"Unable to find RSP file at '{rspFilePath}` at path. Falling back on default values."); + return null; + } + _logger.LogInformation($"Discovered an RSP file at '{rspFilePath}' - will use this file to discover CSX namespaces and references."); return CSharpCommandLineParser.Script.Parse(new string[] { $"@{rspFilePath}" }, _env.TargetDirectory, @@ -98,6 +104,14 @@ private CSharpCompilationOptions CreateCompilationOptions() _logger.LogDebug($"CSX global using statement: {ns}"); } + if(csharpCommandLineArguments != null) + { + foreach(var error in csharpCommandLineArguments.Errors) + { + _logger.LogError($"CSX RSP parse error. {error.GetMessage()}"); + } + } + var metadataReferenceResolver = CreateMetadataReferenceResolver(csharpCommandLineArguments?.ReferencePaths); var sourceResolver = CreateScriptSourceResolver(csharpCommandLineArguments?.SourcePaths);