Skip to content

Commit 5a60a07

Browse files
committed
C#: Allow specifying package feeds for dotnet restore as command line arguments
1 parent f04a69e commit 5a60a07

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DotNet.cs

+10
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ private string GetRestoreArgs(RestoreSettings restoreSettings)
6767
args += $" --configfile \"{restoreSettings.PathToNugetConfig}\"";
6868
}
6969

70+
// Add package sources. If any are present, they override all sources specified in
71+
// the configuration file(s).
72+
if (restoreSettings.Sources != null)
73+
{
74+
foreach (string source in restoreSettings.Sources)
75+
{
76+
args += $" -s {source}";
77+
}
78+
}
79+
7080
if (restoreSettings.ForceReevaluation)
7181
{
7282
args += " --force";

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/IDotNet.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public interface IDotNet
1717
IList<string> GetNugetFeedsFromFolder(string folderPath);
1818
}
1919

20-
public record class RestoreSettings(string File, string PackageDirectory, bool ForceDotnetRefAssemblyFetching, string? PathToNugetConfig = null, bool ForceReevaluation = false, bool TargetWindows = false);
20+
public record class RestoreSettings(string File, string PackageDirectory, bool ForceDotnetRefAssemblyFetching, IList<string>? Sources = null, string? PathToNugetConfig = null, bool ForceReevaluation = false, bool TargetWindows = false);
2121

2222
public partial record class RestoreResult(bool Success, IList<string> Output)
2323
{

0 commit comments

Comments
 (0)