diff --git a/csharp/extractor/Semmle.Extraction.CSharp.Standalone/BuildAnalysis.cs b/csharp/extractor/Semmle.Extraction.CSharp.Standalone/BuildAnalysis.cs index 47bdd3ae568..fc974c7ded6 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.Standalone/BuildAnalysis.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.Standalone/BuildAnalysis.cs @@ -100,6 +100,18 @@ namespace Semmle.BuildAnalyser dllDirNames.Add(runtimeLocation); } + if (options.UseMscorlib) + { + // Add mscorlib.dll or System.Private.CoreLib.dll to the list of DLLs to reference. + var loc = typeof(object).Assembly.Location; + var dir = Path.GetDirectoryName(loc); + if (dir != null) + { + progressMonitor.Log(Util.Logging.Severity.Debug, $"Adding folder {dir} to DLL search path."); + dllDirNames.Add(dir); + } + } + // These files can sometimes prevent `dotnet restore` from working correctly. using (new FileRenamer(sourceDir.GetFiles("global.json", SearchOption.AllDirectories))) using (new FileRenamer(sourceDir.GetFiles("Directory.Build.props", SearchOption.AllDirectories))) @@ -122,11 +134,6 @@ namespace Semmle.BuildAnalyser ResolveConflicts(); - if (options.UseMscorlib) - { - UseReference(typeof(object).Assembly.Location); - } - // Output the findings foreach (var r in usedReferences.Keys) {