@@ -21,9 +21,9 @@ 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 testMatch = false ;
2425 local dotnetRunNeedsSeparator = false ;
2526 local dotnetRunInjectionIndex = nil ;
26- local libOrExe = false ;
2727 local argv = compilerArguments .argv
2828 if OperatingSystem == ' windows' then
2929 -- let's hope that this split matches the escaping rules `dotnet` applies to command line arguments
@@ -35,7 +35,7 @@ function RegisterExtractorPack(id)
3535 -- dotnet options start with either - or / (both are legal)
3636 local firstCharacter = string.sub (arg , 1 , 1 )
3737 if not (firstCharacter == ' -' ) and not (firstCharacter == ' /' ) then
38- if (not match ) then
38+ if (not match and not testMatch ) then
3939 Log (1 , ' Dotnet subcommand detected: %s' , arg )
4040 end
4141 if arg == ' build' or arg == ' msbuild' or arg == ' publish' or arg == ' pack' then
@@ -50,12 +50,12 @@ function RegisterExtractorPack(id)
5050 dotnetRunInjectionIndex = i + 1
5151 end
5252 if arg == ' test' then
53- match = true
53+ testMatch = true
5454 end
5555 -- for `dotnet test`, we should not append `-p:UseSharedCompilation=false` to the command line
5656 -- if a library or executable is being provided as an argument.
57- if arg :match (' %.exe$' ) or arg :match (' %.dll' ) then
58- libOrExe = true
57+ if testMatch and ( arg :match (' %.exe$' ) or arg :match (' %.dll' ) ) then
58+ testMatch = false
5959 end
6060 end
6161 -- if we see a separator to `dotnet run`, inject just prior to the existing separator
@@ -71,7 +71,7 @@ function RegisterExtractorPack(id)
7171 dotnetRunInjectionIndex = i
7272 end
7373 end
74- if match and not libOrExe then
74+ if match or testMatch then
7575 local injections = { ' -p:UseSharedCompilation=false' , ' -p:EmitCompilerGeneratedFiles=true' }
7676 if dotnetRunNeedsSeparator then
7777 table.insert (injections , ' --' )
0 commit comments