Use build-compile from KoreBuild
This commit is contained in:
parent
8503e161d0
commit
be1b128dbf
|
|
@ -8,19 +8,55 @@ use-standard-lifecycle
|
||||||
k-standard-goals
|
k-standard-goals
|
||||||
|
|
||||||
var Configuration_Local = '${E("Configuration")}'
|
var Configuration_Local = '${E("Configuration")}'
|
||||||
var ROOT_Local = '${Directory.GetCurrentDirectory()}'
|
default BASE_DIR_LOCAL='${Directory.GetCurrentDirectory()}'
|
||||||
var BUILD_DIR_Local = '${Path.Combine(ROOT_Local, "build")}'
|
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")
|
Directory.CreateDirectory(TARGET_DIR_LOCAL);
|
||||||
.ToList();
|
|
||||||
|
string commitHash = null;
|
||||||
projectFiles.ForEach(projectFile => DotnetPack(projectFile, BUILD_DIR_Local, Configuration_Local));
|
if (AddAssemblyInfo)
|
||||||
|
|
||||||
foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR_Local, "*/*.nupkg")))
|
|
||||||
{
|
{
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue