@@ -2,29 +2,75 @@ function RegisterExtractorPack(id)
22 local extractor = GetPlatformToolsDirectory () ..
33 ' Semmle.Extraction.CSharp.Driver'
44 if OperatingSystem == ' windows' then extractor = extractor .. ' .exe' end
5+
6+ function DotnetMatcherBuild (compilerName , compilerPath , compilerArguments ,
7+ _languageId )
8+ if compilerName ~= ' dotnet' and compilerName ~= ' dotnet.exe' then
9+ return nil
10+ end
11+
12+ -- The dotnet CLI has the following usage instructions:
13+ -- dotnet [sdk-options] [command] [command-options] [arguments]
14+ -- we are interested in dotnet build, which has the following usage instructions:
15+ -- dotnet [options] build [<PROJECT | SOLUTION>...]
16+ -- For now, parse the command line as follows:
17+ -- Everything that starts with `-` (or `/`) will be ignored.
18+ -- The first non-option argument is treated as the command.
19+ -- if that's `build`, we append `/p:UseSharedCompilation=false` to the command line,
20+ -- otherwise we do nothing.
21+ local match = false
22+ local argv = compilerArguments .argv
23+ if OperatingSystem == ' windows' then
24+ -- let's hope that this split matches the escaping rules `dotnet` applies to command line arguments
25+ -- or, at least, that it is close enough
26+ argv =
27+ NativeArgumentsToArgv (compilerArguments .nativeArgumentPointer )
28+ end
29+ for i , arg in ipairs (argv ) do
30+ -- dotnet options start with either - or / (both are legal)
31+ local firstCharacter = string.sub (arg , 1 , 1 )
32+ if not (firstCharacter == ' -' ) and not (firstCharacter == ' /' ) then
33+ Log (1 , ' Dotnet subcommand detected: %s' , arg )
34+ if arg == ' build' then match = true end
35+ break
36+ end
37+ end
38+ if match then
39+ return {
40+ order = ORDER_REPLACE ,
41+ invocation = BuildExtractorInvocation (id , compilerPath ,
42+ compilerPath ,
43+ compilerArguments , nil , {
44+ ' /p:UseSharedCompilation=false'
45+ })
46+ }
47+ end
48+ return nil
49+ end
50+
551 local windowsMatchers = {
52+ DotnetMatcherBuild ,
653 CreatePatternMatcher ({' ^dotnet%.exe$' }, MatchCompilerName , extractor , {
754 prepend = {' --dotnetexec' , ' --cil' },
855 order = ORDER_BEFORE
956 }),
1057 CreatePatternMatcher ({' ^csc.*%.exe$' }, MatchCompilerName , extractor , {
1158 prepend = {' --compiler' , ' "${compiler}"' , ' --cil' },
1259 order = ORDER_BEFORE
13-
1460 }),
1561 CreatePatternMatcher ({' ^fakes.*%.exe$' , ' moles.*%.exe' },
1662 MatchCompilerName , nil , {trace = false })
1763 }
1864 local posixMatchers = {
19- CreatePatternMatcher ({' ^mcs%.exe$' , ' ^csc%.exe$' }, MatchCompilerName ,
65+ DotnetMatcherBuild ,
66+ CreatePatternMatcher ({' ^mono' , ' ^dotnet$' }, MatchCompilerName ,
2067 extractor , {
21- prepend = {' --compiler ' , ' "${compiler}" ' , ' --cil' },
68+ prepend = {' --dotnetexec ' , ' --cil' },
2269 order = ORDER_BEFORE
23-
2470 }),
25- CreatePatternMatcher ({' ^mono ' , ' ^dotnet $' }, MatchCompilerName ,
71+ CreatePatternMatcher ({' ^mcs%.exe$ ' , ' ^csc%.exe $' }, MatchCompilerName ,
2672 extractor , {
27- prepend = {' --dotnetexec ' , ' --cil' },
73+ prepend = {' --compiler ' , ' "${compiler}" ' , ' --cil' },
2874 order = ORDER_BEFORE
2975 }), function (compilerName , compilerPath , compilerArguments , _languageId )
3076 if MatchCompilerName (' ^msbuild$' , compilerName , compilerPath ,
@@ -49,7 +95,6 @@ function RegisterExtractorPack(id)
4995 else
5096 return posixMatchers
5197 end
52-
5398end
5499
55100-- Return a list of minimum supported versions of the configuration file format
0 commit comments