@@ -21,8 +21,8 @@ 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 needsSeparator = false ;
25
- local injectionIndex = nil ;
24
+ local dotnetRunNeedsSeparator = false ;
25
+ local dotnetRunInjectionIndex = nil ;
26
26
local argv = compilerArguments .argv
27
27
if OperatingSystem == ' windows' then
28
28
-- let's hope that this split matches the escaping rules `dotnet` applies to command line arguments
@@ -34,7 +34,9 @@ function RegisterExtractorPack(id)
34
34
-- dotnet options start with either - or / (both are legal)
35
35
local firstCharacter = string.sub (arg , 1 , 1 )
36
36
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
38
40
if arg == ' build' or arg == ' msbuild' or arg == ' publish' or arg == ' pack' or arg == ' test' then
39
41
match = true
40
42
break
@@ -43,22 +45,29 @@ function RegisterExtractorPack(id)
43
45
-- for `dotnet run`, we need to make sure that `-p:UseSharedCompilation=false` is
44
46
-- not passed in as an argument to the program that is run
45
47
match = true
46
- needsSeparator = true
47
- injectionIndex = i + 1
48
+ dotnetRunNeedsSeparator = true
49
+ dotnetRunInjectionIndex = i + 1
48
50
end
49
51
end
52
+ -- if we see a separator to `dotnet run`, inject just prior to the existing separator
50
53
if arg == ' --' then
51
- needsSeparator = false
52
- injectionIndex = i
54
+ dotnetRunNeedsSeparator = false
55
+ dotnetRunInjectionIndex = i
53
56
break
54
57
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
55
64
end
56
65
if match then
57
66
local injections = { ' -p:UseSharedCompilation=false' }
58
- if needsSeparator then
67
+ if dotnetRunNeedsSeparator then
59
68
table.insert (injections , ' --' )
60
69
end
61
- if injectionIndex == nil then
70
+ if dotnetRunInjectionIndex == nil then
62
71
-- Simple case; just append at the end
63
72
return {
64
73
order = ORDER_REPLACE ,
@@ -69,7 +78,7 @@ function RegisterExtractorPack(id)
69
78
70
79
-- Complex case; splice injections into the middle of the command line
71
80
for i , injectionArg in ipairs (injections ) do
72
- table.insert (argv , injectionIndex + i - 1 , injectionArg )
81
+ table.insert (argv , dotnetRunInjectionIndex + i - 1 , injectionArg )
73
82
end
74
83
75
84
if OperatingSystem == ' windows' then
0 commit comments