@@ -54,7 +54,7 @@ public class RunCommand
5454
5555 /// <summary>
5656 /// Parsed structure representing the MSBuild arguments that will be used to build the project.
57- ///
57+ ///
5858 /// Note: This property has a private setter and is mutated within the class when framework selection modifies it.
5959 /// This mutability is necessary to allow the command to update MSBuild arguments after construction based on framework selection.
6060 /// </summary>
@@ -468,7 +468,8 @@ static ProjectInstance EvaluateProject(string? projectFilePath, Func<ProjectColl
468468
469469 static void ValidatePreconditions ( ProjectInstance project )
470470 {
471- if ( string . IsNullOrWhiteSpace ( project . GetPropertyValue ( "TargetFramework" ) ) )
471+ // there must be some kind of TFM available to run a project
472+ if ( string . IsNullOrWhiteSpace ( project . GetPropertyValue ( "TargetFramework" ) ) && string . IsNullOrEmpty ( project . GetPropertyValue ( "TargetFrameworks" ) ) )
472473 {
473474 ThrowUnableToRunError ( project ) ;
474475 }
@@ -853,11 +854,11 @@ private void SendProjectBasedTelemetry(ProjectLaunchSettingsModel? launchSetting
853854 {
854855 Debug . Assert ( ProjectFileFullPath != null ) ;
855856 var projectIdentifier = RunTelemetry . GetProjectBasedIdentifier ( ProjectFileFullPath , GetRepositoryRoot ( ) , Sha256Hasher . Hash ) ;
856-
857+
857858 // Get package and project reference counts for project-based apps
858859 int packageReferenceCount = 0 ;
859860 int projectReferenceCount = 0 ;
860-
861+
861862 // Try to get project information for telemetry if we built the project
862863 if ( ShouldBuild )
863864 {
@@ -866,10 +867,10 @@ private void SendProjectBasedTelemetry(ProjectLaunchSettingsModel? launchSetting
866867 var globalProperties = MSBuildArgs . GlobalProperties ? . ToDictionary ( ) ?? new Dictionary < string , string > ( StringComparer . OrdinalIgnoreCase ) ;
867868 globalProperties [ Constants . EnableDefaultItems ] = "false" ;
868869 globalProperties [ Constants . MSBuildExtensionsPath ] = AppContext . BaseDirectory ;
869-
870+
870871 using var collection = new ProjectCollection ( globalProperties : globalProperties ) ;
871872 var project = collection . LoadProject ( ProjectFileFullPath ) . CreateProjectInstance ( ) ;
872-
873+
873874 packageReferenceCount = RunTelemetry . CountPackageReferences ( project ) ;
874875 projectReferenceCount = RunTelemetry . CountProjectReferences ( project ) ;
875876 }
@@ -898,10 +899,10 @@ private void SendProjectBasedTelemetry(ProjectLaunchSettingsModel? launchSetting
898899 {
899900 try
900901 {
901- var currentDir = ProjectFileFullPath != null
902+ var currentDir = ProjectFileFullPath != null
902903 ? Path . GetDirectoryName ( ProjectFileFullPath )
903904 : Directory . GetCurrentDirectory ( ) ;
904-
905+
905906 while ( currentDir != null )
906907 {
907908 if ( Directory . Exists ( Path . Combine ( currentDir , ".git" ) ) )
@@ -915,7 +916,7 @@ private void SendProjectBasedTelemetry(ProjectLaunchSettingsModel? launchSetting
915916 {
916917 // Ignore errors when trying to find repo root
917918 }
918-
919+
919920 return null ;
920921 }
921922}
0 commit comments