Skip to content

Commit 1561605

Browse files
committed
尝试删除文件
1 parent bcc339e commit 1561605

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

Code/UsingMSBuildCopyOutputFileToFastDebug/Program.cs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ static int Main(string[] args)
3333

3434
try
3535
{
36-
return CommandLine.Parse(args).AddHandler<CleanOptions>(c => { Logger.Message($"Enter CleanOptions"); })
36+
return CommandLine.Parse(args).AddHandler<CleanOptions>(c =>
37+
{
38+
Logger.Message($"Enter CleanOptions");
39+
CleanFile(c);
40+
})
3741
.AddHandler<CopyOutputFileOptions>(c =>
3842
{
3943
Logger.Message($"Enter CopyOutputFileOptions");
@@ -48,6 +52,35 @@ static int Main(string[] args)
4852
}
4953
}
5054

55+
private static void CleanFile(CleanOptions cleanOptions)
56+
{
57+
try
58+
{
59+
var cleanFileList = File.ReadAllLines(cleanOptions.CleanFilePath);
60+
foreach (var file in cleanFileList)
61+
{
62+
try
63+
{
64+
if (File.Exists(file))
65+
{
66+
File.Delete(file);
67+
Logger.Message($"Deleted files: {file}");
68+
}
69+
}
70+
catch
71+
{
72+
// 删除失败忽略
73+
}
74+
}
75+
76+
File.Delete(cleanOptions.CleanFilePath);
77+
}
78+
catch
79+
{
80+
// 删除失败忽略
81+
}
82+
}
83+
5184
private static void CopyOutputFile(CopyOutputFileOptions copyOutputFileOptions)
5285
{
5386
var launchMainProjectExecutableFile = GetLaunchMainProjectExecutablePath(copyOutputFileOptions);

build/Version.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>1.3.215</Version>
3+
<Version>1.3.216</Version>
44
</PropertyGroup>
55
</Project>

0 commit comments

Comments
 (0)