File tree Expand file tree Collapse file tree
Code/UsingMSBuildCopyOutputFileToFastDebug Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ public bool Execute()
2222 if ( ! File . Exists ( file ) )
2323 {
2424 Console . WriteLine ( $ "找不到{ file } 文件,读取结束") ;
25- return true ;
25+ return false ;
2626 }
2727
2828 var text = File . ReadAllText ( file ) ;
@@ -52,7 +52,7 @@ public bool Execute()
5252 }
5353 }
5454
55- return true ;
55+ return false ;
5656 }
5757
5858 public string LaunchMainProjectPath { set ; get ; }
Original file line number Diff line number Diff line change @@ -66,10 +66,28 @@ private static DirectoryInfo GetTargetFolder(CopyOutputFileOptions copyOutputFil
6666 // 如果用户有设置此文件夹,那就期望是输出到此文件夹
6767 if ( ! string . IsNullOrEmpty ( mainProjectPath ) )
6868 {
69+ if ( Directory . Exists ( mainProjectPath ) is false )
70+ {
71+ throw new DirectoryNotFoundException (
72+ $ "Can not find '{ mainProjectPath } ' FullPath={ Path . GetFullPath ( mainProjectPath ) } ") ;
73+ }
74+
6975 return new DirectoryInfo ( mainProjectPath ) ;
7076 }
77+ // 尝试去读取 LaunchSettings 文件
78+ var launchSettingsParser = new LaunchSettingsParser ( ) ;
79+ if ( launchSettingsParser . Execute ( ) )
80+ {
81+ var launchMainProjectPath = launchSettingsParser . LaunchMainProjectPath ;
82+ if ( Directory . Exists ( launchMainProjectPath ) is false )
83+ {
84+ throw new DirectoryNotFoundException ( $ "Can not find '{ launchMainProjectPath } '") ;
85+ }
86+
87+ return new DirectoryInfo ( launchMainProjectPath ) ;
88+ }
7189
72- return null ;
90+ throw new ArgumentException ( $ "没有从 MainProjectPath 和 LaunchSettings 获取到输出的文件夹" ) ;
7391 }
7492
7593 private static IMSBuildLogger Logger { get ; } = new MSBuildConsoleLogger ( ) ;
You can’t perform that action at this time.
0 commit comments