@@ -21,8 +21,8 @@ function RegisterExtractorPack(id)
2121 -- 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 ;
25- local injectionIndex = nil ;
24+ local dotnetRunNeedsSeparator = false ;
25+ local dotnetRunInjectionIndex = nil ;
2626 local argv = compilerArguments .argv
2727 if OperatingSystem == ' windows' then
2828 -- let's hope that this split matches the escaping rules `dotnet` applies to command line arguments
@@ -34,7 +34,9 @@ function RegisterExtractorPack(id)
3434 -- dotnet options start with either - or / (both are legal)
3535 local firstCharacter = string.sub (arg , 1 , 1 )
3636 if not (firstCharacter == ' -' ) and not (firstCharacter == ' /' ) then
37- Log (1 , ' Dotnet subcommand detected: %s' , arg )
37+ if (not match ) then
38+ Log (1 , ' Dotnet subcommand detected: %s' , arg )
39+ end
3840 if arg == ' build' or arg == ' msbuild' or arg == ' publish' or arg == ' pack' or arg == ' test' then
3941 match = true
4042 break
@@ -43,22 +45,29 @@ function RegisterExtractorPack(id)
4345 -- for `dotnet run`, we need to make sure that `-p:UseSharedCompilation=false` is
4446 -- not passed in as an argument to the program that is run
4547 match = true
46- needsSeparator = true
47- injectionIndex = i + 1
48+ dotnetRunNeedsSeparator = true
49+ dotnetRunInjectionIndex = i + 1
4850 end
4951 end
52+ -- if we see a separator to `dotnet run`, inject just prior to the existing separator
5053 if arg == ' --' then
51- needsSeparator = false
52- injectionIndex = i
54+ dotnetRunNeedsSeparator = false
55+ dotnetRunInjectionIndex = i
5356 break
5457 end
58+ -- if we see an option to `dotnet run` (e.g., `--project`), inject just prior
59+ -- to the last option
60+ if firstCharacter == ' -' then
61+ dotnetRunNeedsSeparator = false
62+ dotnetRunInjectionIndex = i
63+ end
5564 end
5665 if match then
5766 local injections = { ' -p:UseSharedCompilation=false' }
58- if needsSeparator then
67+ if dotnetRunNeedsSeparator then
5968 table.insert (injections , ' --' )
6069 end
61- if injectionIndex == nil then
70+ if dotnetRunInjectionIndex == nil then
6271 -- Simple case; just append at the end
6372 return {
6473 order = ORDER_REPLACE ,
@@ -69,7 +78,7 @@ function RegisterExtractorPack(id)
6978
7079 -- Complex case; splice injections into the middle of the command line
7180 for i , injectionArg in ipairs (injections ) do
72- table.insert (argv , injectionIndex + i - 1 , injectionArg )
81+ table.insert (argv , dotnetRunInjectionIndex + i - 1 , injectionArg )
7382 end
7483
7584 if OperatingSystem == ' windows' then
0 commit comments