@@ -22,6 +22,7 @@ function RegisterExtractorPack(id)
2222 -- otherwise we do nothing.
2323 local match = false
2424 local needsSeparator = false ;
25+ local injectionIndex = nil ;
2526 local argv = compilerArguments .argv
2627 if OperatingSystem == ' windows' then
2728 -- let's hope that this split matches the escaping rules `dotnet` applies to command line arguments
@@ -38,13 +39,60 @@ function RegisterExtractorPack(id)
3839 match = true
3940 break
4041 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
4154 end
4255 end
4356 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
4896 end
4997 return nil
5098 end
0 commit comments