-
Notifications
You must be signed in to change notification settings - Fork 2
/
PreSharpBuildTask.cs
76 lines (57 loc) · 2.56 KB
/
PreSharpBuildTask.cs
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
[LoadInSeparateAppDomain]
public class PreSharpBuildTask : AppDomainIsolatedTask {
[Required]
public string ConditionalCompilationSymbols { get; set; }
[Required]
public ITaskItem[] InPlaceFiles { get; set; }
[Required]
public ITaskItem[] TemplateFiles { get; set; }
[Required]
public ITaskItem[] TemplateIncludeFiles { get; set; }
[Required]
public ITaskItem[] TemplateLibraryFiles { get; set; }
[Required]
public ITaskItem[] DependencyPaths { get; set; }
[Required]
public string OutputDirectory { get; set; }
[Required]
public string ProjectPath { get; set; }
[Output]
public ITaskItem[] CompileGeneratedFiles { get; set; }
[Output]
public ITaskItem[] EmbeddedResourceGeneratedFiles { get; set; }
[Output]
public ITaskItem[] FilesToDelete { get; set; }
public override bool Execute() {
TaskLogger logger = new TaskLogger(this);
List<string> compileGeneratedFiles;
List<string> embeddedResourceGeneratedFiles;
List<string> filesToDelete;
bool debugMode = (ConditionalCompilationSymbols.Contains("PRESHARP_DEBUG") || Environment.GetEnvironmentVariable("PRESHARP_DEBUG") != null) &&
!(ConditionalCompilationSymbols.Contains("DISABLE_PRESHARP_DEBUG") || Environment.GetEnvironmentVariable("DISABLE_PRESHARP_DEBUG") != null);
PreSharpEntryPoint.Process(
logger,
InPlaceFiles.Select(taskItem => taskItem.ItemSpec),
TemplateFiles.Select(taskItem => taskItem.ItemSpec),
TemplateIncludeFiles.Select(taskItem => taskItem.ItemSpec),
TemplateLibraryFiles.Select(taskItem => taskItem.ItemSpec),
DependencyPaths.Select(taskItem => taskItem.ItemSpec),
Path.GetFullPath(Path.Combine(Path.GetDirectoryName(ProjectPath), OutputDirectory)),
out compileGeneratedFiles,
out embeddedResourceGeneratedFiles,
out filesToDelete,
/*createNewAppDomain*/false,
/*debugMode*/debugMode,
ConditionalCompilationSymbols);
CompileGeneratedFiles = compileGeneratedFiles.Select(file => new TaskItem(file)).ToArray();
EmbeddedResourceGeneratedFiles = embeddedResourceGeneratedFiles.Select(file => new TaskItem(file)).ToArray();
FilesToDelete = filesToDelete.Select(file => new TaskItem(file)).ToArray();
return logger.Success;
}
}