forked from MonoGame/MonoGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
145 lines (121 loc) · 4.15 KB
/
build.cake
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#tool nuget:?package=vswhere&version=2.6.7
#tool nuget:?package=NUnit.ConsoleRunner&version=3.4.0
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("build-target", "Default");
var version = Argument("build-version", "1.0.0.0");
var configuration = Argument("build-configuration", "Release");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
MSBuildSettings msPackSettings;
DotNetCoreMSBuildSettings dnBuildSettings;
DotNetCorePackSettings dnPackSettings;
FilePath androidToolPath;
FilePath uwpToolPath;
private MSBuildSettings GetMSBuildPackSettings()
{
var s = new MSBuildSettings();
s.Verbosity = Verbosity.Minimal;
s.Configuration = configuration;
s.WithProperty("Version", version);
s.WithTarget("Pack");
return s;
}
private void PackProject(string filePath)
{
// Windows and Linux dotnet tool does not allow building of .NET
// projects, as such we must call msbuild on these platforms.
if (IsRunningOnWindows())
DotNetCorePack(filePath, dnPackSettings);
else
MSBuild(filePath, msPackSettings);
}
private FilePath GetMSBuildWith(string requires)
{
if (IsRunningOnWindows())
{
DirectoryPath vsLatest = VSWhereLatest(new VSWhereLatestSettings { Requires = requires});
if (vsLatest != null)
{
var files = GetFiles(vsLatest.FullPath + "/**/MSBuild.exe");
if (files.Any())
return files.First();
}
}
return null;
}
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Prep")
.Does(() =>
{
msPackSettings = GetMSBuildPackSettings();
dnPackSettings = new DotNetCorePackSettings();
dnPackSettings.MSBuildSettings = dnBuildSettings;
dnPackSettings.Verbosity = DotNetCoreVerbosity.Minimal;
dnPackSettings.Configuration = configuration;
androidToolPath = GetMSBuildWith("Component.Xamarin");
if (IsRunningOnWindows())
uwpToolPath = GetMSBuildWith("Microsoft.VisualStudio.Component.Windows10SDK.17763");
});
Task("BuildDesktopGL")
.IsDependentOn("Prep")
.Does(() =>
{
DotNetCoreRestore("MonoGame.Framework.DesktopGL.sln");
PackProject("MonoGame.Framework/MonoGame.Framework.DesktopGL.csproj");
});
Task("BuildWindowsDX")
.IsDependentOn("Prep")
.Does(() =>
{
DotNetCoreRestore("MonoGame.Framework.WindowsDX.sln");
PackProject("MonoGame.Framework/MonoGame.Framework.WindowsDX.csproj");
});
Task("BuildAndroid")
.IsDependentOn("Prep")
.Does(() =>
{
if (androidToolPath != null)
{
var packSettings = GetMSBuildPackSettings();
packSettings.ToolPath = androidToolPath;
DotNetCoreRestore("MonoGame.Framework/MonoGame.Framework.AndroidCore.csproj");
MSBuild("MonoGame.Framework/MonoGame.Framework.AndroidCore.csproj", packSettings);
}
else
{
Warning("Skipping Android build: MSBuild not found or Xamarin is not installed.");
}
});
Task("BuildUWP")
.IsDependentOn("Prep")
.Does(() =>
{
if (uwpToolPath != null)
{
var packSettings = GetMSBuildPackSettings();
packSettings.ToolPath = uwpToolPath;
DotNetCoreRestore("MonoGame.Framework/MonoGame.Framework.UWP.csproj");
MSBuild("MonoGame.Framework/MonoGame.Framework.UWP.csproj", packSettings);
}
else
{
Warning("Skipping UWP build: MSBuild not found or UWP workload (with SDK 17763) is not installed.");
}
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("BuildDesktopGL")
.IsDependentOn("BuildWindowsDX")
.IsDependentOn("BuildAndroid")
.IsDependentOn("BuildUWP");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);