@@ -83,7 +83,11 @@ public static async Task<ProjectMetadata> GetProjectMetadata(
83
83
84
84
var args = CreateMsBuildArguments ( file , framework , configuration , runtime , noBuild , outputPath ) ;
85
85
86
- var metadata = await TryReadingUsingGetProperties ( args , file , noBuild ) ?? await ReadUsingMsBuildTargets ( args , file , buildExtensionsDir , console ) ;
86
+ var metadata = await TryReadingUsingGetProperties ( args , file , noBuild ) ;
87
+ if ( metadata == null || string . IsNullOrWhiteSpace ( metadata [ nameof ( ProjectDir ) ] ) )
88
+ {
89
+ metadata = await ReadUsingMsBuildTargets ( args , file , buildExtensionsDir , console ) ;
90
+ }
87
91
88
92
var platformTarget = metadata [ nameof ( PlatformTarget ) ] ;
89
93
if ( platformTarget . Length == 0 )
@@ -225,7 +229,8 @@ private static async Task<Dictionary<string, string>> TryReadingUsingGetProperti
225
229
nameof ( ProjectDir ) ,
226
230
nameof ( ProjectRuntimeConfigFilePath ) ,
227
231
nameof ( TargetFileName ) ,
228
- nameof ( TargetFrameworkIdentifier )
232
+ nameof ( TargetFrameworkIdentifier ) ,
233
+ "MSBuildProjectDirectory" ,
229
234
} ;
230
235
231
236
try
@@ -251,6 +256,12 @@ private static async Task<Dictionary<string, string>> TryReadingUsingGetProperti
251
256
. EnumerateObject ( )
252
257
. ToDictionary ( x => x . Name , x => x . Value . ToString ( ) . Trim ( ) ) ;
253
258
259
+ // depending on the project type or MSBuild evaluation process, the ProjectDir property may not be set
260
+ if ( string . IsNullOrWhiteSpace ( metadata [ nameof ( ProjectDir ) ] ) )
261
+ {
262
+ metadata [ nameof ( ProjectDir ) ] = metadata [ "MSBuildProjectDirectory" ] ;
263
+ }
264
+
254
265
return metadata ;
255
266
}
256
267
}
0 commit comments