C#: Make sure that the file exists before attempting to get version info.

This commit is contained in:
Michael Nebel
2025-10-21 13:12:21 +02:00
parent af5622a60e
commit def522d122

View File

@@ -76,7 +76,7 @@ namespace Semmle.Extraction.CSharp
// If csc is specified as compiler name, then attempt to read the version information from csc.dll
var compilerBinaryName = Path.GetFileName(SpecifiedCompiler) == "csc" ? $"{SpecifiedCompiler}.dll" : SpecifiedCompiler;
var versionInfo = FileVersionInfo.GetVersionInfo(compilerBinaryName);
var versionInfo = FileVersionInfo.GetVersionInfo(File.Exists(compilerBinaryName) ? compilerBinaryName : SpecifiedCompiler);
if (!knownCompilerNames.TryGetValue(versionInfo.OriginalFilename ?? string.Empty, out var vendor))
{
SkipExtractionBecause("the compiler name is not recognised");