-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProjectBuilder.cs
63 lines (54 loc) · 2.1 KB
/
ProjectBuilder.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
using Microsoft.Build.Evaluation;
using Microsoft.Build.Framework;
using System.Collections.Generic;
namespace CaravelEditor
{
class ProjectBuilder
{
public static bool Build(string projectPath, string outputDirectory, EditorBuildLogger logger, out string assemblyName)
{
List<ILogger> loggers = new List<ILogger>();
loggers.Add(logger);
string projectFilePath = projectPath;
ProjectCollection pc = new ProjectCollection();
pc.RegisterLogger(logger);
Dictionary<string, string> globalProperty = new Dictionary<string, string>();
globalProperty.Add("OutputPath", outputDirectory);
//BuildParameters bp = new BuildParameters(pc);
//BuildRequestData buildRequest = new BuildRequestData(projectFilePath, globalProperty, "4.0", new string[] { "Build" }, null);
try
{
pc.LoadProject(projectFilePath, globalProperty, "4.0");
//BuildResult buildResult = BuildManager.DefaultBuildManager.Build(bp, buildRequest);
foreach (var proj in pc.LoadedProjects)
{
if (proj.Build())
{
logger.WriteLine("Build Finished!");
assemblyName = proj.GetPropertyValue("AssemblyName");
return true;
}
else
{
logger.WriteLine("Build Failed!");
assemblyName = "";
return false;
}
}
assemblyName = "";
return false;
/*if (buildResult.OverallResult == BuildResultCode.Success)
{
//...
logger.WriteLine("Build Finished!");
return true;
}
return false;*/
}
finally
{
pc.UnregisterAllLoggers();
}
}
}
}