Use build-compile from KoreBuild

This commit is contained in:
Pranav K 2016-03-23 08:36:30 -07:00
parent 8503e161d0
commit be1b128dbf
1 changed files with 47 additions and 11 deletions

View File

@ -8,19 +8,55 @@ use-standard-lifecycle
k-standard-goals
var Configuration_Local = '${E("Configuration")}'
var ROOT_Local = '${Directory.GetCurrentDirectory()}'
var BUILD_DIR_Local = '${Path.Combine(ROOT_Local, "build")}'
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='IsLinux && Directory.Exists("src")'
#build-compile target='compile' if='Directory.Exists("src")'
@{
var projectFiles = Files.Include("src/**/project.json")
.Exclude("src/Microsoft.AspNetCore.DataProtection.SystemWeb/project.json")
.ToList();
projectFiles.ForEach(projectFile => DotnetPack(projectFile, BUILD_DIR_Local, Configuration_Local));
foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR_Local, "*/*.nupkg")))
Directory.CreateDirectory(TARGET_DIR_LOCAL);
string commitHash = null;
if (AddAssemblyInfo)
{
File.Copy(nupkg, Path.Combine(BUILD_DIR_Local, Path.GetFileName(nupkg)), true);
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/Microsoft.AspNetCore.DataProtection.SystemWeb/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);
}
}