Skip to content

Commit 94ad965

Browse files
committed
更改变量名,不再通过文件夹方法
使用文件的优势在于判断框架,因为输出文件夹也许存在多个可执行文件,混合不同框架
1 parent 3ce98be commit 94ad965

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

Code/ToolPackager/Build/dotnetCampus.UsingMSBuildCopyOutputFileToFastDebug.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232

3333
<PropertyGroup>
3434
<OutputFileToCopyList>"@(OutputFileToCopy)"</OutputFileToCopyList>
35-
<MainProjectPathCommandArgs Condition="'$(MainProjectPath)' != ''">-MainProjectPath $(MainProjectPath)</MainProjectPathCommandArgs>
35+
<MainProjectExecutablePathCommandArgs Condition="'$(MainProjectExecutablePath)' != ''">-MainProjectExecutablePath $(MainProjectExecutablePath)</MainProjectExecutablePathCommandArgs>
3636
</PropertyGroup>
3737

38-
<Exec Command="dotnet $(UsingMSBuildCopyOutputFileToFastDebugTaskFile) -- CopyOutputFile $(MainProjectPathCommandArgs) -CleanFilePath $(CleanUsingMSBuildCopyOutputFileToFastDebugFile) -OutputFileToCopyList $(OutputFileToCopyList) -TargetFramework $(TargetFramework)"/>
38+
<Exec Command="dotnet $(UsingMSBuildCopyOutputFileToFastDebugTaskFile) -- CopyOutputFile $(MainProjectExecutablePathCommandArgs) -CleanFilePath $(CleanUsingMSBuildCopyOutputFileToFastDebugFile) -OutputFileToCopyList $(OutputFileToCopyList) -TargetFramework $(TargetFramework)"/>
3939
</Target>
4040

4141
<!--<Target Name="ParseLaunchSettings" AfterTargets="AfterBuild"

Code/UsingMSBuildCopyOutputFileToFastDebug/Program.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private static void CopyOutputFile(CopyOutputFileOptions copyOutputFileOptions)
7878
/// <returns></returns>
7979
private static FileInfo GetLaunchMainProjectExecutablePath(CopyOutputFileOptions copyOutputFileOptions)
8080
{
81-
var mainProjectPath = copyOutputFileOptions.MainProjectPath;
81+
var mainProjectPath = copyOutputFileOptions.MainProjectExecutablePath;
8282
// 如果用户有设置此文件夹,那就期望是输出到此文件夹
8383
if (!string.IsNullOrEmpty(mainProjectPath))
8484
{
@@ -114,7 +114,7 @@ private static FileInfo GetLaunchMainProjectExecutablePath(CopyOutputFileOptions
114114
return new FileInfo(launchMainProjectExecutablePath!);
115115
}
116116

117-
throw new ArgumentException($"没有从 MainProjectPath 和 LaunchSettings 获取到输出的文件夹");
117+
throw new ArgumentException($"没有从 MainProjectExecutablePath 和 LaunchSettings 获取到输出的文件夹");
118118
}
119119

120120
private static IMSBuildLogger Logger { get; } = new MSBuildConsoleLogger();
@@ -132,8 +132,8 @@ public static bool CheckCanCopy(DirectoryInfo targetFolder, CopyOutputFileOption
132132
[Verb("CopyOutputFile")]
133133
public class CopyOutputFileOptions
134134
{
135-
[Option("MainProjectPath")]
136-
public string MainProjectPath { set; get; } = null!;
135+
[Option("MainProjectExecutablePath")]
136+
public string MainProjectExecutablePath { set; get; } = null!;
137137

138138
[Option("CleanFilePath")]
139139
public string CleanFilePath { set; get; }

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,23 @@
2828

2929
通过右击底层库属性,点击调试,设置为可执行文件,路径修改为主项目的启动程序。就可以在底层库点击调试运行主项目调试,同时支持打断点和进行二进制兼容的更改
3030

31+
请注意,将使用首个可执行文件调试配置作为输出配置
32+
3133
**高级方法**
3234

3335
编辑底层库项目的 csproj 文件,添加下面代码
3436

3537
```xml
3638
<PropertyGroup>
37-
<MainProjectPath>主项目的输出文件夹</MainProjectPath>
39+
<MainProjectPath>主项目的输出可执行文件</MainProjectPath>
3840
</PropertyGroup>
3941
```
4042

4143
请注意如果路径包含空格,记得加上引号,如下面例子
4244

4345
```xml
4446
<PropertyGroup>
45-
<MainProjectPath>"C:\dotnet campus\Foo\bin\release\net5.0"</MainProjectPath>
47+
<MainProjectExecutablePathCommandArgs>"C:\dotnet campus\Foo\bin\release\net5.0\Foo.exe"</MainProjectPath>
4648
</PropertyGroup>
4749
```
4850

0 commit comments

Comments
 (0)