@@ -151,7 +151,6 @@ private static CompilerInvocation TryGetInvocationFromTask(Microsoft.Build.Loggi
151
151
152
152
public static string TrimCompilerExeFromCommandLine ( string commandLine , CompilerKind language )
153
153
{
154
-
155
154
var stringsToTrim = new [ ]
156
155
{
157
156
"csc.exe " ,
@@ -170,21 +169,8 @@ public static string TrimCompilerExeFromCommandLine(string commandLine, Compiler
170
169
}
171
170
}
172
171
173
- var i1 = commandLine . IndexOf ( "dotnet.exe" , StringComparison . Ordinal ) ;
174
- var i2 = commandLine . IndexOf ( " exec " , StringComparison . Ordinal ) ;
175
- var i3 = commandLine . IndexOf ( "csc.dll" , StringComparison . Ordinal ) ;
176
- if ( i3 == - 1 )
177
- {
178
- i3 = commandLine . IndexOf ( "vbc.dll" , StringComparison . Ordinal ) ;
179
- }
180
-
181
- if ( i1 != - 1 &&
182
- i2 != - 1 &&
183
- i3 != - 1 &&
184
- i1 < i2 &&
185
- i2 < i3 )
172
+ string TrimHere ( int i )
186
173
{
187
- var i = i3 + "csc.dll" . Length ;
188
174
if ( commandLine [ i ] == '"' )
189
175
{
190
176
i ++ ;
@@ -198,6 +184,43 @@ public static string TrimCompilerExeFromCommandLine(string commandLine, Compiler
198
184
return commandLine . Substring ( i ) ;
199
185
}
200
186
187
+ {
188
+ // Trim dotnet cli csc of vbc invocation
189
+
190
+ var i1 = commandLine . IndexOf ( "dotnet.exe" , StringComparison . OrdinalIgnoreCase ) ;
191
+ var i2 = commandLine . IndexOf ( " exec " , StringComparison . OrdinalIgnoreCase ) ;
192
+ var i3 = commandLine . IndexOf ( "csc.dll" , StringComparison . OrdinalIgnoreCase ) ;
193
+ if ( i3 == - 1 )
194
+ {
195
+ i3 = commandLine . IndexOf ( "vbc.dll" , StringComparison . OrdinalIgnoreCase ) ;
196
+ }
197
+
198
+ if ( i1 != - 1 &&
199
+ i2 != - 1 &&
200
+ i3 != - 1 &&
201
+ i1 < i2 &&
202
+ i2 < i3 )
203
+ {
204
+ return TrimHere ( i3 + "csc.dll" . Length ) ;
205
+ }
206
+ }
207
+
208
+ {
209
+ // Trim full path csc.exe or vbc.exe invocation
210
+
211
+ var i1 = commandLine . IndexOf ( "csc.exe" , StringComparison . OrdinalIgnoreCase ) ;
212
+ if ( i1 == - 1 )
213
+ {
214
+ i1 = commandLine . IndexOf ( "vbc.exe" , StringComparison . OrdinalIgnoreCase ) ;
215
+ }
216
+
217
+ if ( i1 != - 1 )
218
+ {
219
+ return TrimHere ( i1 + "csc.exe" . Length ) ;
220
+ }
221
+
222
+ }
223
+
201
224
return commandLine ;
202
225
}
203
226
0 commit comments