Skip to content

Commit

Permalink
C#: Initialise DependabotProxy in DotNetCliInvoker
Browse files Browse the repository at this point in the history
  • Loading branch information
mbg committed Nov 19, 2024
1 parent f346e38 commit b1828a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private DotNet(IDotNetCliInvoker dotnetCliInvoker, ILogger logger, TemporaryDire
Info();
}

private DotNet(ILogger logger, string? dotNetPath, TemporaryDirectory tempWorkingDirectory) : this(new DotNetCliInvoker(logger, Path.Combine(dotNetPath ?? string.Empty, "dotnet")), logger, tempWorkingDirectory) { }
private DotNet(ILogger logger, string? dotNetPath, TemporaryDirectory tempWorkingDirectory) : this(new DotNetCliInvoker(logger, Path.Combine(dotNetPath ?? string.Empty, "dotnet"), tempWorkingDirectory), logger, tempWorkingDirectory) { }

internal static IDotNet Make(IDotNetCliInvoker dotnetCliInvoker, ILogger logger) => new DotNet(dotnetCliInvoker, logger);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
internal sealed class DotNetCliInvoker : IDotNetCliInvoker
{
private readonly ILogger logger;
private readonly DependabotProxy proxy;

public string Exec { get; }

public DotNetCliInvoker(ILogger logger, string exec)
public DotNetCliInvoker(ILogger logger, string exec, TemporaryDirectory tempWorkingDirectory)
{
this.logger = logger;
this.proxy = new DependabotProxy(tempWorkingDirectory);
this.Exec = exec;
logger.LogInfo($"Using .NET CLI executable: '{Exec}'");
}
Expand All @@ -38,6 +40,14 @@ private ProcessStartInfo MakeDotnetStartInfo(string args, string? workingDirecto
startInfo.EnvironmentVariables["DOTNET_CLI_UI_LANGUAGE"] = "en";
startInfo.EnvironmentVariables["MSBUILDDISABLENODEREUSE"] = "1";
startInfo.EnvironmentVariables["DOTNET_SKIP_FIRST_TIME_EXPERIENCE"] = "true";

// Configure the proxy settings, if applicable.
this.proxy.ApplyProxy(this.logger, startInfo);

this.logger.LogInfo(startInfo.EnvironmentVariables["HTTP_PROXY"] ?? "");
this.logger.LogInfo(startInfo.EnvironmentVariables["HTTPS_PROXY"] ?? "");
this.logger.LogInfo(startInfo.EnvironmentVariables["SSL_CERT_FILE"] ?? "");

return startInfo;
}

Expand Down

0 comments on commit b1828a8

Please sign in to comment.