@@ -10,7 +10,8 @@ namespace Semmle.Autobuild.Shared
1010 /// </summary>
1111 public class AutobuildOptions
1212 {
13- private const string prefix = "LGTM_INDEX_" ;
13+ private const string lgtmPrefix = "LGTM_INDEX_" ;
14+ private const string extractorOptionPrefix = "CODEQL_EXTRACTOR_CSHARP_OPTION_" ;
1415
1516 public int SearchDepth { get ; } = 3 ;
1617 public string RootDirectory { get ; }
@@ -36,20 +37,21 @@ public class AutobuildOptions
3637 public AutobuildOptions ( IBuildActions actions , Language language )
3738 {
3839 RootDirectory = actions . GetCurrentDirectory ( ) ;
39- VsToolsVersion = actions . GetEnvironmentVariable ( prefix + "VSTOOLS_VERSION" ) ;
40- MsBuildArguments = actions . GetEnvironmentVariable ( prefix + "MSBUILD_ARGUMENTS" ) ? . AsStringWithExpandedEnvVars ( actions ) ;
41- MsBuildPlatform = actions . GetEnvironmentVariable ( prefix + "MSBUILD_PLATFORM" ) ;
42- MsBuildConfiguration = actions . GetEnvironmentVariable ( prefix + "MSBUILD_CONFIGURATION" ) ;
43- MsBuildTarget = actions . GetEnvironmentVariable ( prefix + "MSBUILD_TARGET" ) ;
44- DotNetArguments = actions . GetEnvironmentVariable ( prefix + "DOTNET_ARGUMENTS" ) ? . AsStringWithExpandedEnvVars ( actions ) ;
45- DotNetVersion = actions . GetEnvironmentVariable ( prefix + "DOTNET_VERSION" ) ;
46- BuildCommand = actions . GetEnvironmentVariable ( prefix + "BUILD_COMMAND" ) ;
47- Solution = actions . GetEnvironmentVariable ( prefix + "SOLUTION" ) . AsListWithExpandedEnvVars ( actions , Array . Empty < string > ( ) ) ;
40+ VsToolsVersion = actions . GetEnvironmentVariable ( lgtmPrefix + "VSTOOLS_VERSION" ) ;
41+ MsBuildArguments = actions . GetEnvironmentVariable ( lgtmPrefix + "MSBUILD_ARGUMENTS" ) ? . AsStringWithExpandedEnvVars ( actions ) ;
42+ MsBuildPlatform = actions . GetEnvironmentVariable ( lgtmPrefix + "MSBUILD_PLATFORM" ) ;
43+ MsBuildConfiguration = actions . GetEnvironmentVariable ( lgtmPrefix + "MSBUILD_CONFIGURATION" ) ;
44+ MsBuildTarget = actions . GetEnvironmentVariable ( lgtmPrefix + "MSBUILD_TARGET" ) ;
45+ DotNetArguments = actions . GetEnvironmentVariable ( lgtmPrefix + "DOTNET_ARGUMENTS" ) ? . AsStringWithExpandedEnvVars ( actions ) ;
46+ DotNetVersion = actions . GetEnvironmentVariable ( lgtmPrefix + "DOTNET_VERSION" ) ;
47+ BuildCommand = actions . GetEnvironmentVariable ( lgtmPrefix + "BUILD_COMMAND" ) ;
48+ Solution = actions . GetEnvironmentVariable ( lgtmPrefix + "SOLUTION" ) . AsListWithExpandedEnvVars ( actions , Array . Empty < string > ( ) ) ;
4849
49- IgnoreErrors = actions . GetEnvironmentVariable ( prefix + "IGNORE_ERRORS" ) . AsBool ( "ignore_errors" , false ) ;
50- Buildless = actions . GetEnvironmentVariable ( prefix + "BUILDLESS" ) . AsBool ( "buildless" , false ) ;
51- AllSolutions = actions . GetEnvironmentVariable ( prefix + "ALL_SOLUTIONS" ) . AsBool ( "all_solutions" , false ) ;
52- NugetRestore = actions . GetEnvironmentVariable ( prefix + "NUGET_RESTORE" ) . AsBool ( "nuget_restore" , true ) ;
50+ IgnoreErrors = actions . GetEnvironmentVariable ( lgtmPrefix + "IGNORE_ERRORS" ) . AsBool ( "ignore_errors" , false ) ;
51+ Buildless = actions . GetEnvironmentVariable ( lgtmPrefix + "BUILDLESS" ) . AsBool ( "buildless" , false ) ||
52+ actions . GetEnvironmentVariable ( extractorOptionPrefix + "BUILDLESS" ) . AsBool ( "buildless" , false ) ;
53+ AllSolutions = actions . GetEnvironmentVariable ( lgtmPrefix + "ALL_SOLUTIONS" ) . AsBool ( "all_solutions" , false ) ;
54+ NugetRestore = actions . GetEnvironmentVariable ( lgtmPrefix + "NUGET_RESTORE" ) . AsBool ( "nuget_restore" , true ) ;
5355
5456 Language = language ;
5557 }
@@ -62,21 +64,12 @@ public static bool AsBool(this string? value, string param, bool defaultValue)
6264 if ( value is null )
6365 return defaultValue ;
6466
65- switch ( value . ToLower ( ) )
67+ return value . ToLower ( ) switch
6668 {
67- case "on" :
68- case "yes" :
69- case "true" :
70- case "enabled" :
71- return true ;
72- case "off" :
73- case "no" :
74- case "false" :
75- case "disabled" :
76- return false ;
77- default :
78- throw new ArgumentOutOfRangeException ( param , value , "The Boolean value is invalid." ) ;
79- }
69+ "on" or "yes" or "true" or "enabled" => true ,
70+ "off" or "no" or "false" or "disabled" => false ,
71+ _ => throw new ArgumentOutOfRangeException ( param , value , "The Boolean value is invalid." ) ,
72+ } ;
8073 }
8174
8275 public static string [ ] AsListWithExpandedEnvVars ( this string ? value , IBuildActions actions , string [ ] defaultValue )
0 commit comments