@@ -22,6 +22,7 @@ function RegisterExtractorPack(id)
22
22
-- otherwise we do nothing.
23
23
local match = false
24
24
local needsSeparator = false ;
25
+ local injectionIndex = nil ;
25
26
local argv = compilerArguments .argv
26
27
if OperatingSystem == ' windows' then
27
28
-- let's hope that this split matches the escaping rules `dotnet` applies to command line arguments
@@ -38,13 +39,60 @@ function RegisterExtractorPack(id)
38
39
match = true
39
40
break
40
41
end
42
+ if arg == ' run' then
43
+ -- for `dotnet run`, we need to make sure that `-p:UseSharedCompilation=false` is
44
+ -- not passed in as an argument to the program that is run
45
+ match = true
46
+ needsSeparator = true
47
+ injectionIndex = i + 1
48
+ end
49
+ end
50
+ if arg == ' --' then
51
+ needsSeparator = false
52
+ injectionIndex = i
53
+ break
41
54
end
42
55
end
43
56
if match then
44
- return {
45
- order = ORDER_REPLACE ,
46
- invocation = BuildExtractorInvocation (id , compilerPath , compilerPath , compilerArguments , nil , { ' -p:UseSharedCompilation=false' })
47
- }
57
+ local injections = { ' -p:UseSharedCompilation=false' }
58
+ if needsSeparator then
59
+ table.insert (injections , ' --' )
60
+ end
61
+ if injectionIndex == nil then
62
+ -- Simple case; just append at the end
63
+ return {
64
+ order = ORDER_REPLACE ,
65
+ invocation = BuildExtractorInvocation (id , compilerPath , compilerPath , compilerArguments , nil ,
66
+ injections )
67
+ }
68
+ end
69
+
70
+ -- Complex case; splice injections into the middle of the command line
71
+ for i , injectionArg in ipairs (injections ) do
72
+ table.insert (argv , injectionIndex + i - 1 , injectionArg )
73
+ end
74
+
75
+ if OperatingSystem == ' windows' then
76
+ return {
77
+ order = ORDER_REPLACE ,
78
+ invocation = {
79
+ path = AbsolutifyExtractorPath (id , compilerPath ),
80
+ arguments = {
81
+ commandLineString = table.concat (argv , " " )
82
+ }
83
+ }
84
+ }
85
+ else
86
+ return {
87
+ order = ORDER_REPLACE ,
88
+ invocation = {
89
+ path = AbsolutifyExtractorPath (id , compilerPath ),
90
+ arguments = {
91
+ argv = argv
92
+ }
93
+ }
94
+ }
95
+ end
48
96
end
49
97
return nil
50
98
end
0 commit comments