C#: Make sure System.Private.CoreLib is added only once as a reference in standalone extraction

This commit is contained in:
Tamas Vajk
2023-06-09 11:10:32 +02:00
parent 0cef5651e2
commit bf3677df16

View File

@@ -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)
{