Skip to content

Commit

Permalink
Merge pull request OmniSharp#2008 from ByronMayne/master
Browse files Browse the repository at this point in the history
Response file can now used enviroment variables in the path + more error handling.
  • Loading branch information
filipw authored Nov 20, 2020
2 parents 9086daf + 914d6b5 commit 6389c11
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/OmniSharp.Script/ScriptOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, ReportDiagnostic> NullableDiagnostics => _nullableDiagnostics.Value;
Expand Down
16 changes: 15 additions & 1 deletion src/OmniSharp.Script/ScriptProjectProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
Expand Down Expand Up @@ -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,
Expand All @@ -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);

Expand Down

0 comments on commit 6389c11

Please sign in to comment.