Skip to content

Commit bf3677d

Browse files
committed
C#: Make sure System.Private.CoreLib is added only once as a reference in standalone extraction
1 parent 0cef565 commit bf3677d

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ public BuildAnalysis(Options options, IProgressMonitor progress)
100100
dllDirNames.Add(runtimeLocation);
101101
}
102102

103+
if (options.UseMscorlib)
104+
{
105+
// Add mscorlib.dll or System.Private.CoreLib.dll to the list of DLLs to reference.
106+
var loc = typeof(object).Assembly.Location;
107+
var dir = Path.GetDirectoryName(loc);
108+
if (dir != null)
109+
{
110+
progressMonitor.Log(Util.Logging.Severity.Debug, $"Adding folder {dir} to DLL search path.");
111+
dllDirNames.Add(dir);
112+
}
113+
}
114+
103115
// These files can sometimes prevent `dotnet restore` from working correctly.
104116
using (new FileRenamer(sourceDir.GetFiles("global.json", SearchOption.AllDirectories)))
105117
using (new FileRenamer(sourceDir.GetFiles("Directory.Build.props", SearchOption.AllDirectories)))
@@ -122,11 +134,6 @@ public BuildAnalysis(Options options, IProgressMonitor progress)
122134

123135
ResolveConflicts();
124136

125-
if (options.UseMscorlib)
126-
{
127-
UseReference(typeof(object).Assembly.Location);
128-
}
129-
130137
// Output the findings
131138
foreach (var r in usedReferences.Keys)
132139
{

0 commit comments

Comments
 (0)