diff --git a/src/dotnet/commands/dotnet-compile/CompilerUtil.cs b/src/dotnet/commands/dotnet-compile/CompilerUtil.cs index 6f888a916..962046303 100644 --- a/src/dotnet/commands/dotnet-compile/CompilerUtil.cs +++ b/src/dotnet/commands/dotnet-compile/CompilerUtil.cs @@ -26,12 +26,29 @@ namespace Microsoft.DotNet.Tools.Compiler return compilerName; } - + + private static readonly KeyValuePair[] s_compilerNameToLanguageId = + { + new KeyValuePair("csc", "cs"), + new KeyValuePair("vbc", "vb"), + new KeyValuePair("fsc", "fs") + }; + public static string ResolveLanguageId(ProjectContext context) { var languageId = context.ProjectFile.AnalyzerOptions?.LanguageId; - languageId = languageId ?? "cs"; - + if (languageId == null) + { + var compilerName = ResolveCompilerName(context); + foreach (var kvp in s_compilerNameToLanguageId) + { + if (kvp.Key == compilerName) + { + languageId = kvp.Value; + } + } + } + return languageId; }