C#: Rename ExtraArgs to NugetSources.

This commit is contained in:
Michael Nebel
2026-04-10 11:47:12 +02:00
parent 8369c926b1
commit 1ee6d631c6
3 changed files with 11 additions and 11 deletions

View File

@@ -95,9 +95,9 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
args += " /p:EnableWindowsTargeting=true";
}
if (restoreSettings.ExtraArgs is not null)
if (restoreSettings.NugetSources is not null)
{
args += $" {restoreSettings.ExtraArgs}";
args += $" {restoreSettings.NugetSources}";
}
return args;

View File

@@ -17,7 +17,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
IList<string> GetNugetFeedsFromFolder(string folderPath);
}
public record class RestoreSettings(string File, string PackageDirectory, bool ForceDotnetRefAssemblyFetching, string? ExtraArgs = null, string? PathToNugetConfig = null, bool ForceReevaluation = false, bool TargetWindows = false);
public record class RestoreSettings(string File, string PackageDirectory, bool ForceDotnetRefAssemblyFetching, string? NugetSources = null, string? PathToNugetConfig = null, bool ForceReevaluation = false, bool TargetWindows = false);
public partial record class RestoreResult(bool Success, IList<string> Output)
{

View File

@@ -118,7 +118,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
compilationInfoContainer.CompilationInfos.Add(("NuGet feed responsiveness checked", CheckNugetFeedResponsiveness ? "1" : "0"));
HashSet<string> explicitFeeds = [];
string? explicitRestoreSources = null;
string? explicitNugetSources = null;
try
{
@@ -153,13 +153,13 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
// If feed responsiveness is being checked, we only want to use the feeds that are reachable (note this set includes private
// registry feeds if they are reachable).
explicitRestoreSources = MakeRestoreSourcesArgument(reachableFeeds);
explicitNugetSources = MakeRestoreSourcesArgument(reachableFeeds);
}
else if (HasPrivateRegistryFeeds)
{
// If private registries are configured they need to be included as sources for the restore, which requires that
// they are provided as source arguments for the restore. The private registries are included in the `allFeeds` set.
explicitRestoreSources = MakeRestoreSourcesArgument(allFeeds);
explicitNugetSources = MakeRestoreSourcesArgument(allFeeds);
}
using (var nuget = new NugetExeWrapper(fileProvider, legacyPackageDirectory, logger))
@@ -202,9 +202,9 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
}
// Restore project dependencies with `dotnet restore`.
var restoredProjects = RestoreSolutions(explicitRestoreSources, out var container);
var restoredProjects = RestoreSolutions(explicitNugetSources, out var container);
var projects = fileProvider.Projects.Except(restoredProjects);
RestoreProjects(projects, explicitRestoreSources, out var containers);
RestoreProjects(projects, explicitNugetSources, out var containers);
var dependencies = containers.Flatten(container);
@@ -291,7 +291,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
/// Populates dependencies with the relevant dependencies from the assets files generated by the restore.
/// Returns a list of projects that are up to date with respect to restore.
/// </summary>
private IEnumerable<string> RestoreSolutions(string? explicitRestoreSources, out DependencyContainer dependencies)
private IEnumerable<string> RestoreSolutions(string? nugetSources, out DependencyContainer dependencies)
{
var successCount = 0;
var nugetSourceFailures = 0;
@@ -302,7 +302,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
var projects = fileProvider.Solutions.SelectMany(solution =>
{
logger.LogInfo($"Restoring solution {solution}...");
var res = dotnet.Restore(new(solution, PackageDirectory.DirInfo.FullName, ForceDotnetRefAssemblyFetching: true, ExtraArgs: explicitRestoreSources, TargetWindows: isWindows));
var res = dotnet.Restore(new(solution, PackageDirectory.DirInfo.FullName, ForceDotnetRefAssemblyFetching: true, NugetSources: nugetSources, TargetWindows: isWindows));
if (res.Success)
{
successCount++;
@@ -357,7 +357,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
foreach (var project in projectGroup)
{
logger.LogInfo($"Restoring project {project}...");
var res = dotnet.Restore(new(project, PackageDirectory.DirInfo.FullName, ForceDotnetRefAssemblyFetching: true, ExtraArgs: explicitRestoreSources, TargetWindows: isWindows));
var res = dotnet.Restore(new(project, PackageDirectory.DirInfo.FullName, ForceDotnetRefAssemblyFetching: true, NugetSources: explicitRestoreSources, TargetWindows: isWindows));
assets.AddDependenciesRange(res.AssetsFilePaths);
lock (sync)
{