Build projects in one go
This commit is contained in:
parent
bc98fcbce4
commit
f377542e38
|
|
@ -33,4 +33,12 @@ functions
|
||||||
return Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME") != null;
|
return Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME") != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
bool IsBuildV2
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Environment.GetEnvironmentVariable("KOREBUILD_BUILD_V2") == "1";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -30,6 +30,8 @@ default Quiet='${ false }'
|
||||||
Configuration = "Debug";
|
Configuration = "Debug";
|
||||||
E("Configuration", Configuration);
|
E("Configuration", Configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.Info("Build v2: " + IsBuildV2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#restore-npm-modules
|
#restore-npm-modules
|
||||||
|
|
@ -88,19 +90,27 @@ default Quiet='${ false }'
|
||||||
|
|
||||||
#build-compile target='compile' if='Directory.Exists("src")'
|
#build-compile target='compile' if='Directory.Exists("src")'
|
||||||
@{
|
@{
|
||||||
var projectFiles = Files.Include("src/**/project.json").ToList();
|
if (IsBuildV2)
|
||||||
if (ShouldRunInParallel)
|
|
||||||
{
|
{
|
||||||
Parallel.ForEach(projectFiles, projectFile => DnuPack(projectFile, BUILD_DIR, Configuration));
|
const string buildPattern = "src/**";
|
||||||
|
DnuPack(buildPattern, BUILD_DIR, Configuration);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
projectFiles.ForEach(projectFile => DnuPack(projectFile, BUILD_DIR, Configuration));
|
var projectFiles = Files.Include("src/**/project.json").ToList();
|
||||||
|
if (ShouldRunInParallel)
|
||||||
|
{
|
||||||
|
Parallel.ForEach(projectFiles, projectFile => DnuPack(projectFile, BUILD_DIR, Configuration));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
projectFiles.ForEach(projectFile => DnuPack(projectFile, BUILD_DIR, Configuration));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR, "*/*.nupkg")))
|
foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR, "*/*.nupkg")))
|
||||||
{
|
{
|
||||||
File.Copy(nupkg, Path.Combine(BUILD_DIR, Path.GetFileName(nupkg)), true);
|
File.Copy(nupkg, Path.Combine(BUILD_DIR, Path.GetFileName(nupkg)), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -227,16 +237,16 @@ functions @{
|
||||||
if(!IsLinux)
|
if(!IsLinux)
|
||||||
{
|
{
|
||||||
processStartInfo = new ProcessStartInfo {
|
processStartInfo = new ProcessStartInfo {
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
FileName = "cmd",
|
FileName = "cmd",
|
||||||
Arguments = "/C " + program + " " + commandline,
|
Arguments = "/C " + program + " " + commandline,
|
||||||
};
|
};
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
processStartInfo = new ProcessStartInfo {
|
processStartInfo = new ProcessStartInfo {
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
FileName = program,
|
FileName = program,
|
||||||
Arguments = commandline,
|
Arguments = commandline,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
|
|
@ -283,4 +293,9 @@ macro name="DnuBuild" projectFile='string' configuration='string'
|
||||||
|
|
||||||
macro name="DnuPack" projectFile='string' kpmPackOutputDir='string' configuration='string'
|
macro name="DnuPack" projectFile='string' kpmPackOutputDir='string' configuration='string'
|
||||||
kpm-pack
|
kpm-pack
|
||||||
|
|
||||||
|
macro name="DeleteFolder" delete='string'
|
||||||
|
directory
|
||||||
|
|
||||||
|
macro name="CopyFolder" sourceDir='string' outputDir='string'
|
||||||
|
copy
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,47 @@ configuration=''
|
||||||
|
|
||||||
default configuration = 'Debug'
|
default configuration = 'Debug'
|
||||||
default build_options='${E("NUGET3_build_options")}'
|
default build_options='${E("NUGET3_build_options")}'
|
||||||
var projectFolder='${Path.GetDirectoryName(projectFile)}'
|
|
||||||
var projectName='${Path.GetFileName(projectFolder)}'
|
|
||||||
var projectBin='${Path.Combine(projectFolder, "bin", configuration)}'
|
|
||||||
|
|
||||||
directory delete="${projectBin}"
|
@{
|
||||||
exec program='cmd' commandline='/C dnu build${build_options} ${projectFolder} --configuration ${configuration}' if='!IsMono'
|
if (IsBuildV2)
|
||||||
exec program='dnu' commandline='build${build_options} ${projectFolder} --configuration ${configuration}' if='IsMono'
|
{
|
||||||
|
var projectFolders = projectFile.Split((char)';')
|
||||||
|
.SelectMany(pattern => Files.Include(pattern + "/project.json"))
|
||||||
|
.Select(proj => Path.GetDirectoryName(proj))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
foreach(var projFolder in projectFolders)
|
||||||
|
{
|
||||||
|
DeleteFolder(Path.Combine(projFolder, "bin", configuration));
|
||||||
|
}
|
||||||
|
|
||||||
|
var projectsArg=projectFile.Replace(";", " ");
|
||||||
|
var dnuArgs=string.Format("build{0} {1} --configuration {2}", build_options, projectsArg, configuration);
|
||||||
|
if (!IsMono)
|
||||||
|
{
|
||||||
|
Exec("cmd", "/C dnu " + dnuArgs);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Exec("dnu", dnuArgs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var projectFolder=Path.GetDirectoryName(projectFile);
|
||||||
|
var projectName=Path.GetFileName(projectFolder);
|
||||||
|
var projectBin=Path.Combine(projectFolder, "bin", configuration);
|
||||||
|
|
||||||
|
DeleteFolder(projectBin);
|
||||||
|
|
||||||
|
var dnuArgs=string.Format("build{0} {1} --configuration {2}", build_options, projectFolder, configuration);
|
||||||
|
if (!IsMono)
|
||||||
|
{
|
||||||
|
Exec("cmd", "/C dnu " + dnuArgs);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Exec("dnu", dnuArgs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -15,11 +15,56 @@ configuration=''
|
||||||
|
|
||||||
default configuration = 'Debug'
|
default configuration = 'Debug'
|
||||||
default pack_options='${E("NUGET3_pack_options")}'
|
default pack_options='${E("NUGET3_pack_options")}'
|
||||||
var projectFolder='${Path.GetDirectoryName(projectFile)}'
|
|
||||||
var projectName='${Path.GetFileName(projectFolder)}'
|
|
||||||
var projectBin='${Path.Combine(projectFolder, "bin", configuration)}'
|
|
||||||
|
|
||||||
directory delete="${projectBin}"
|
@{
|
||||||
exec program='cmd' commandline='/C dnu pack${pack_options} ${projectFolder} --configuration ${configuration}' if='!IsMono'
|
if (IsBuildV2)
|
||||||
exec program='dnu' commandline='pack${pack_options} ${projectFolder} --configuration ${configuration}' if='IsMono'
|
{
|
||||||
copy sourceDir='${projectBin}' outputDir='${Path.Combine(kpmPackOutputDir, projectName)}'
|
var projectFolders = projectFile.Split((char)';')
|
||||||
|
.SelectMany(pattern => Files.Include(pattern + "/project.json"))
|
||||||
|
.Select(proj => Path.GetDirectoryName(proj))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
foreach(var projFolder in projectFolders)
|
||||||
|
{
|
||||||
|
DeleteFolder(Path.Combine(projFolder, "bin", configuration));
|
||||||
|
}
|
||||||
|
|
||||||
|
var projectsArg=projectFile.Replace(";", " ");
|
||||||
|
var dnuArgs=string.Format("pack{0} {1} --configuration {2}", pack_options, projectsArg, configuration);
|
||||||
|
if (!IsMono)
|
||||||
|
{
|
||||||
|
Exec("cmd", "/C dnu " + dnuArgs);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Exec("dnu", dnuArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(var projFolder in projectFolders)
|
||||||
|
{
|
||||||
|
CopyFolder(
|
||||||
|
Path.Combine(projFolder, "bin", configuration),
|
||||||
|
Path.Combine(kpmPackOutputDir, Path.GetFileName(projFolder)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var projectFolder=Path.GetDirectoryName(projectFile);
|
||||||
|
var projectName=Path.GetFileName(projectFolder);
|
||||||
|
var projectBin=Path.Combine(projectFolder, "bin", configuration);
|
||||||
|
|
||||||
|
DeleteFolder(projectBin);
|
||||||
|
|
||||||
|
var dnuArgs=string.Format("pack{0} {1} --configuration {2}", pack_options, projectFolder, configuration);
|
||||||
|
if (!IsMono)
|
||||||
|
{
|
||||||
|
Exec("cmd", "/C dnu " + dnuArgs);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Exec("dnu", dnuArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
CopyFolder(projectBin, Path.Combine(kpmPackOutputDir, projectName));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue