-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile.shade
75 lines (61 loc) · 2.67 KB
/
makefile.shade
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
use import="Environment"
var VERSION='0.1'
var FULL_VERSION='0.1'
var AUTHORS='Microsoft Open Technologies, Inc.'
use-standard-lifecycle
k-standard-goals
var Configuration_Local = '${E("Configuration")}'
default BASE_DIR_LOCAL='${Directory.GetCurrentDirectory()}'
default TARGET_DIR_LOCAL='${Path.Combine(BASE_DIR_LOCAL, "artifacts")}'
default BUILD_DIR_LOCAL='${Path.Combine(TARGET_DIR_LOCAL, "build")}'
#build-compile target='compile' if='Directory.Exists("src")'
@{
Directory.CreateDirectory(TARGET_DIR_LOCAL);
string commitHash = null;
if (AddAssemblyInfo)
{
var commitHashFile = Path.Combine(TARGET_DIR_LOCAL, "commit");
GitCommand("rev-parse HEAD >> " + commitHashFile);
commitHash = File.ReadAllLines(commitHashFile)[0];
}
var projectFiles = Files.Include("src/*/project.json").ToList();
if (IsLinux)
{
projectFiles.Remove("src/Owin.Security.OpenIdConnect.Extensions/project.json");
projectFiles.Remove("src/Owin.Security.OpenIdConnect.Server/project.json");
}
projectFiles.ForEach(projectFile =>
{
if (AddAssemblyInfo)
{
var projectText = File.ReadAllText(projectFile);
var project = (JsonObject)Json.Deserialize(projectText);
var isSharedProject = project.Keys.Contains("shared");
// We don't want to embed the commit hash in it because
// the consumers would get that file
if (!isSharedProject)
{
Console.WriteLine("Embedding commit hash in assembly");
var projectFolder = Path.GetDirectoryName(projectFile);
var commitHashAttribute = String.Format("[assembly: System.Reflection.AssemblyMetadata(\"CommitHash\", \"{0}\")]", commitHash);
var buildInfoFile = Path.Combine(projectFolder, "BuildInfo.generated.cs");
File.WriteAllText(buildInfoFile, commitHashAttribute);
}
}
DotnetPack(projectFile, BUILD_DIR_LOCAL, Configuration_Local);
});
foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR_LOCAL, "*/" + Configuration_Local + "/*.nupkg")))
{
File.Copy(nupkg, Path.Combine(BUILD_DIR_LOCAL, Path.GetFileName(nupkg)), true);
}
}
#build-samples target='compile' if='Directory.Exists("samples") && !BuildSrcOnly'
@{
var projectFiles = Files.Include("samples/*/*/project.json").ToList();
if (IsLinux)
{
projectFiles.Remove("samples/Nancy/Nancy.Client/project.json");
projectFiles.Remove("samples/Nancy/Nancy.Server/project.json");
}
projectFiles.ForEach(projectFile => DotnetBuild(projectFile, Configuration_Local, E("KOREBUILD_BUILD_FRAMEWORK")));
}