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

Response file can now used enviroment variables in the path + more error handling. #2008

Merged
merged 4 commits into from
Nov 20, 2020
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
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