@@ -211,9 +211,10 @@ public static string DeterminePublishLocation(string workingDirectory, string pr
211211 /// Looks up specified properties from a project.
212212 /// </summary>
213213 /// <param name="projectLocation">The location of the project file.</param>
214+ /// <param name="msBuildParameters">Additional MSBuild parameters passed by the user from the commandline</param>
214215 /// <param name="propertyNames">The names of the properties to look up.</param>
215216 /// <returns>A dictionary of property names and their values.</returns>
216- public static Dictionary < string , string > LookupProjectProperties ( string projectLocation , params string [ ] propertyNames )
217+ public static Dictionary < string , string > LookupProjectProperties ( string projectLocation , string msBuildParameters , params string [ ] propertyNames )
217218 {
218219 var projectFile = FindProjectFileInDirectory ( projectLocation ) ;
219220 var properties = new Dictionary < string , string > ( ) ;
@@ -225,6 +226,11 @@ public static Dictionary<string, string> LookupProjectProperties(string projectL
225226 $ "--getProperty:{ string . Join ( ',' , propertyNames ) } "
226227 } ;
227228
229+ if ( ! string . IsNullOrEmpty ( msBuildParameters ) )
230+ {
231+ arguments . Add ( msBuildParameters ) ;
232+ }
233+
228234 var process = new Process
229235 {
230236 StartInfo = new ProcessStartInfo
@@ -302,16 +308,17 @@ private static Dictionary<string, string> LookupProjectPropertiesFromXml(string
302308 {
303309 }
304310 return properties ;
305- }
311+ }
306312
307313 /// <summary>
308314 /// Looks up the target framework from a project file.
309315 /// </summary>
310316 /// <param name="projectLocation">The location of the project file.</param>
317+ /// <param name="msBuildParameters">Additonal MSBuild paramteres passed by the user from the commandline</param>
311318 /// <returns>The target framework of the project.</returns>
312- public static string LookupTargetFrameworkFromProjectFile ( string projectLocation )
319+ public static string LookupTargetFrameworkFromProjectFile ( string projectLocation , string msBuildParameters )
313320 {
314- var properties = LookupProjectProperties ( projectLocation , "TargetFramework" , "TargetFrameworks" ) ;
321+ var properties = LookupProjectProperties ( projectLocation , msBuildParameters , "TargetFramework" , "TargetFrameworks" ) ;
315322 if ( properties . TryGetValue ( "TargetFramework" , out var targetFramework ) && ! string . IsNullOrEmpty ( targetFramework ) )
316323 {
317324 return targetFramework ;
@@ -331,10 +338,11 @@ public static string LookupTargetFrameworkFromProjectFile(string projectLocation
331338 /// Retrieve the `OutputType` property of a given project
332339 /// </summary>
333340 /// <param name="projectLocation">Path of the project</param>
341+ /// <param name="msBuildParameters">Additonal MSBuild paramteres passed by the user from the commandline</param>
334342 /// <returns>The value of the `OutputType` property</returns>
335- public static string LookupOutputTypeFromProjectFile ( string projectLocation )
343+ public static string LookupOutputTypeFromProjectFile ( string projectLocation , string msBuildParameters )
336344 {
337- var properties = LookupProjectProperties ( projectLocation , "OutputType" ) ;
345+ var properties = LookupProjectProperties ( projectLocation , msBuildParameters , "OutputType" ) ;
338346 return properties . TryGetValue ( "OutputType" , out var outputType ) ? outputType . Trim ( ) : null ;
339347 }
340348
@@ -353,7 +361,7 @@ public static bool LookPublishAotFlag(string projectLocation, string msBuildPara
353361 }
354362 }
355363
356- var properties = LookupProjectProperties ( projectLocation , "PublishAot" ) ;
364+ var properties = LookupProjectProperties ( projectLocation , msBuildParameters , "PublishAot" ) ;
357365 if ( properties . TryGetValue ( "PublishAot" , out var publishAot ) )
358366 {
359367 return bool . TryParse ( publishAot , out var result ) && result ;
@@ -369,7 +377,7 @@ public static bool HasExplicitSelfContainedFlag(string projectLocation, string m
369377 return true ;
370378 }
371379
372- var properties = LookupProjectProperties ( projectLocation , "SelfContained" ) ;
380+ var properties = LookupProjectProperties ( projectLocation , msBuildParameters , "SelfContained" ) ;
373381 if ( properties . TryGetValue ( "SelfContained" , out var selfContained ) )
374382 {
375383 return bool . TryParse ( selfContained , out var isSelfContained ) && isSelfContained ;
0 commit comments