C#: Use ASP.NET dlls when needed and available.

This commit is contained in:
Michael Nebel
2023-08-03 13:10:08 +02:00
parent b71c41018c
commit ca7fa2e7c8
2 changed files with 22 additions and 9 deletions

View File

@@ -63,12 +63,19 @@ namespace Semmle.BuildAnalyser
var dllDirNames = options.DllDirs.Select(Path.GetFullPath).ToList();
// Find DLLs in the .Net Framework
// Find DLLs in the .Net / Asp.Net Framework
if (options.ScanNetFrameworkDlls)
{
var runtimeLocation = new Runtime(dotnet).GetRuntime(options.UseSelfContainedDotnet);
progressMonitor.Log(Util.Logging.Severity.Info, $"Runtime location selected: {runtimeLocation}");
var runtime = new Runtime(dotnet);
var runtimeLocation = runtime.GetRuntime(options.UseSelfContainedDotnet);
progressMonitor.LogInfo($".NET runtime location selected: {runtimeLocation}");
dllDirNames.Add(runtimeLocation);
if (UseAspNetDlls() && runtime.GetAspRuntime() is string aspRuntime)
{
progressMonitor.LogInfo($"ASP.NET runtime location selected: {aspRuntime}");
dllDirNames.Add(aspRuntime);
}
}
if (options.UseMscorlib)

View File

@@ -159,12 +159,6 @@ namespace Semmle.Extraction.CSharp.Standalone
return netCoreVersion.FullPath;
}
// Location of the newest ASP.NET Core Runtime.
if (newestRuntimes.TryGetValue(aspNetCoreApp, out var aspNetCoreVersion))
{
return aspNetCoreVersion.FullPath;
}
if (DesktopRuntimes.Any())
{
return DesktopRuntimes.First();
@@ -173,5 +167,17 @@ namespace Semmle.Extraction.CSharp.Standalone
// A bad choice if it's the self-contained runtime distributed in codeql dist.
return ExecutingRuntime;
}
public string? GetAspRuntime()
{
var newestRuntimes = GetNewestRuntimes();
// Location of the newest ASP.NET Core Runtime.
if (newestRuntimes.TryGetValue(aspNetCoreApp, out var aspNetCoreVersion))
{
return aspNetCoreVersion.FullPath;
}
return null;
}
}
}