@@ -21,9 +21,9 @@ function RegisterExtractorPack(id)
21
21
-- if that's `build`, we append `-p:UseSharedCompilation=false` to the command line,
22
22
-- otherwise we do nothing.
23
23
local match = false
24
+ local testMatch = false ;
24
25
local dotnetRunNeedsSeparator = false ;
25
26
local dotnetRunInjectionIndex = nil ;
26
- local libOrExe = false ;
27
27
local argv = compilerArguments .argv
28
28
if OperatingSystem == ' windows' then
29
29
-- let's hope that this split matches the escaping rules `dotnet` applies to command line arguments
@@ -35,7 +35,7 @@ function RegisterExtractorPack(id)
35
35
-- dotnet options start with either - or / (both are legal)
36
36
local firstCharacter = string.sub (arg , 1 , 1 )
37
37
if not (firstCharacter == ' -' ) and not (firstCharacter == ' /' ) then
38
- if (not match ) then
38
+ if (not match and not testMatch ) then
39
39
Log (1 , ' Dotnet subcommand detected: %s' , arg )
40
40
end
41
41
if arg == ' build' or arg == ' msbuild' or arg == ' publish' or arg == ' pack' then
@@ -50,12 +50,12 @@ function RegisterExtractorPack(id)
50
50
dotnetRunInjectionIndex = i + 1
51
51
end
52
52
if arg == ' test' then
53
- match = true
53
+ testMatch = true
54
54
end
55
55
-- for `dotnet test`, we should not append `-p:UseSharedCompilation=false` to the command line
56
56
-- 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
59
59
end
60
60
end
61
61
-- if we see a separator to `dotnet run`, inject just prior to the existing separator
@@ -71,7 +71,7 @@ function RegisterExtractorPack(id)
71
71
dotnetRunInjectionIndex = i
72
72
end
73
73
end
74
- if match and not libOrExe then
74
+ if match or testMatch then
75
75
local injections = { ' -p:UseSharedCompilation=false' , ' -p:EmitCompilerGeneratedFiles=true' }
76
76
if dotnetRunNeedsSeparator then
77
77
table.insert (injections , ' --' )
0 commit comments