forked from madskristensen/WebCompiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompilerCleanTask.cs
More file actions
49 lines (42 loc) · 1.36 KB
/
CompilerCleanTask.cs
File metadata and controls
49 lines (42 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.IO;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace WebCompiler
{
/// <summary>
/// An MSBuild task for cleaning web compiler output of a given config file.
/// </summary>
public class CompilerCleanTask : Task
{
/// <summary>
/// The file path of the compilerconfig.json file
/// </summary>
public string FileName { get; set; }
/// <summary>
/// Execute the Clean Task
/// </summary>
public override bool Execute()
{
var configFile = new FileInfo(FileName);
if (!configFile.Exists)
{
Log.LogWarning(configFile.FullName + " does not exist");
return true;
}
Log.LogMessage(MessageImportance.High, Environment.NewLine + "WebCompiler: Begin cleaning output of " + configFile.Name);
try
{
var processor = new ConfigFileProcessor();
processor.DeleteOutputFiles(configFile.FullName);
Log.LogMessage(MessageImportance.High, "WebCompiler: Done cleaning output of " + configFile.Name);
return true;
}
catch (Exception ex)
{
Log.LogError(ex.Message);
return false;
}
}
}
}