@@ -18,9 +18,10 @@ function RegisterExtractorPack(id)
1818 -- For now, parse the command line as follows:
1919 -- Everything that starts with `-` (or `/`) will be ignored.
2020 -- The first non-option argument is treated as the command.
21- -- if that's `build`, we append `/ p:UseSharedCompilation=false` to the command line,
21+ -- if that's `build`, we append `- p:UseSharedCompilation=false` to the command line,
2222 -- otherwise we do nothing.
2323 local match = false
24+ local needsSeparator = false ;
2425 local argv = compilerArguments .argv
2526 if OperatingSystem == ' windows' then
2627 -- let's hope that this split matches the escaping rules `dotnet` applies to command line arguments
@@ -33,18 +34,30 @@ function RegisterExtractorPack(id)
3334 local firstCharacter = string.sub (arg , 1 , 1 )
3435 if not (firstCharacter == ' -' ) and not (firstCharacter == ' /' ) then
3536 Log (1 , ' Dotnet subcommand detected: %s' , arg )
36- if arg == ' build' or arg == ' msbuild' then match = true end
37+ if arg == ' build' or arg == ' msbuild' or arg == ' publish' or arg == ' pack' or arg == ' test' then
38+ match = true
39+ break
40+ end
41+ if arg == ' run' then
42+ -- for `dotnet run`, we need to make sure that `-p:UseSharedCompilation=false` is
43+ -- not passed in as an argument to the program that is run
44+ match = true
45+ needsSeparator = true
46+ end
47+ end
48+ if arg == ' --' then
49+ needsSeparator = false
3750 break
3851 end
3952 end
4053 if match then
54+ local injections = { ' -p:UseSharedCompilation=false' }
55+ if needsSeparator then
56+ table.insert (injections , ' --' )
57+ end
4158 return {
4259 order = ORDER_REPLACE ,
43- invocation = BuildExtractorInvocation (id , compilerPath ,
44- compilerPath ,
45- compilerArguments , nil , {
46- ' /p:UseSharedCompilation=false'
47- })
60+ invocation = BuildExtractorInvocation (id , compilerPath , compilerPath , compilerArguments , nil , injections )
4861 }
4962 end
5063 return nil
0 commit comments