Skip to content

Commit cb1b227

Browse files
authored
Merge pull request #6270 from hvitved/csharp/standalone-nuget-restore
C#: Skip `dotnet restore` in standalone extraction when `nuget_restore: false` is set
2 parents 1a59c9b + 6ba6d99 commit cb1b227

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

csharp/extractor/Semmle.Extraction.CSharp.Standalone/BuildAnalysis.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ public BuildAnalysis(Options options, IProgressMonitor progress)
108108
new[] { options.SolutionFile } :
109109
sourceDir.GetFiles("*.sln", SearchOption.AllDirectories).Select(d => d.FullName);
110110

111-
RestoreSolutions(solutions);
111+
if (options.UseNuGet)
112+
{
113+
RestoreSolutions(solutions);
114+
}
112115
dllDirNames.Add(packageDirectory.DirInfo.FullName);
113116
assemblyCache = new BuildAnalyser.AssemblyCache(dllDirNames, progress);
114117
AnalyseSolutions(solutions);
@@ -324,7 +327,16 @@ private void AnalyseProject(FileInfo project)
324327

325328
private void Restore(string projectOrSolution)
326329
{
327-
var exit = DotNet.RestoreToDirectory(projectOrSolution, packageDirectory.DirInfo.FullName);
330+
int exit;
331+
try
332+
{
333+
exit = DotNet.RestoreToDirectory(projectOrSolution, packageDirectory.DirInfo.FullName);
334+
}
335+
catch (FileNotFoundException)
336+
{
337+
exit = 2;
338+
}
339+
328340
switch (exit)
329341
{
330342
case 0:

0 commit comments

Comments
 (0)