217 lines
7.5 KiB
Plaintext
217 lines
7.5 KiB
Plaintext
use assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
|
use namespace="System"
|
|
use namespace="System.IO"
|
|
use import="Files"
|
|
use import="BuildEnv"
|
|
use import="Environment"
|
|
|
|
default BASE_DIR='${Directory.GetCurrentDirectory()}'
|
|
default TARGET_DIR='${Path.Combine(BASE_DIR, "artifacts")}'
|
|
default BUILD_DIR='${Path.Combine(TARGET_DIR, "build")}'
|
|
default TEST_DIR='${Path.Combine(TARGET_DIR, "test")}'
|
|
default Configuration='${E("Configuration")}'
|
|
|
|
@{
|
|
if (string.IsNullOrEmpty(E("DNX_BUILD_VERSION")))
|
|
{
|
|
E("DNX_BUILD_VERSION", BuildNumber);
|
|
}
|
|
if (string.IsNullOrEmpty(E("DNX_AUTHOR")))
|
|
{
|
|
E("DNX_AUTHOR", AUTHORS);
|
|
}
|
|
if (string.IsNullOrEmpty(E("DNX_ASSEMBLY_FILE_VERSION")))
|
|
{
|
|
E("DNX_ASSEMBLY_FILE_VERSION", CreateDayBasedVersionNumber());
|
|
}
|
|
if (string.IsNullOrEmpty(Configuration))
|
|
{
|
|
Configuration = "Debug";
|
|
E("Configuration", Configuration);
|
|
}
|
|
}
|
|
|
|
#restore-npm-modules
|
|
-// Find all dirs that contain a package.json file
|
|
var npmDirs = '${GetDirectoriesContaining(Directory.GetCurrentDirectory(), "package.json")}'
|
|
npm npmCommand='install ${E("npm_install_options")}' each='var npmDir in npmDirs'
|
|
|
|
#restore-bower-components
|
|
-// Find all dirs that contain a bower.json file
|
|
var bowerDirs = '${GetDirectoriesContaining(Directory.GetCurrentDirectory(), "bower.json")}'
|
|
bower each='var bowerDir in bowerDirs' bowerCommand='install ${E("bower_install_options")}'
|
|
|
|
#run-grunt .restore-npm-modules .restore-bower-components target='initialize'
|
|
-// Find all dirs that contain a gruntfile.js file
|
|
var gruntDirs = '${GetDirectoriesContaining(Directory.GetCurrentDirectory(), "gruntfile.js")}'
|
|
grunt each='var gruntDir in gruntDirs'
|
|
|
|
#clean-bin-folder
|
|
rimraf rimrafDir='bin' if='Directory.Exists("bin")'
|
|
|
|
#clean-npm-modules
|
|
-// Find all dirs that contain a package.json file
|
|
var npmDirs = '${
|
|
GetDirectoriesContaining(Directory.GetCurrentDirectory(), "package.json")
|
|
.Select(directory => Path.Combine(directory, "node_modules"))
|
|
.Where(directory => Directory.Exists(directory))
|
|
}'
|
|
rimraf each='var rimrafDir in npmDirs'
|
|
|
|
-// Target order is important because clean-npm-modules may (re)create bin folder.
|
|
#deep-clean .clean-npm-modules .clean-bin-folder description='Clean folders that may cause problems for `git clean`.'
|
|
|
|
#repo-initialize target='initialize'
|
|
k-restore
|
|
|
|
#target-dir-clean target='clean'
|
|
directory delete="${TARGET_DIR}"
|
|
|
|
#build-clean target='clean' if='Directory.Exists("src")'
|
|
k-clean each='var projectFile in Files.Include("src/**/project.json")'
|
|
|
|
#ci-deep-clean .deep-clean target='clean' if='IsTeamCity'
|
|
|
|
#build-compile target='compile' if='Directory.Exists("src")'
|
|
kpm-pack each='var projectFile in Files.Include("src/**/project.json")' configuration='${Configuration}'
|
|
@{
|
|
foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR, "*/*.nupkg")))
|
|
{
|
|
File.Copy(nupkg, Path.Combine(BUILD_DIR, Path.GetFileName(nupkg)), true);
|
|
}
|
|
}
|
|
|
|
#native-compile target='compile' if='!IsMono && Directory.Exists(Path.Combine(BASE_DIR, "src"))'
|
|
var programFilesX86 = '${Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)}'
|
|
var nativeProjects ='${Files.Include(Path.Combine(BASE_DIR, "src", "**", "*.vcxproj"))}'
|
|
|
|
@{
|
|
if (nativeProjects.Any())
|
|
{
|
|
var msbuildVersions = new[] { "14.0", "12.0"};
|
|
|
|
for (var i = 0; i < msbuildVersions.Length; i++)
|
|
{
|
|
var msbuildPath = Path.Combine(programFilesX86, "MSBuild", msbuildVersions[i], "Bin", "MSBuild.exe");
|
|
if (File.Exists(msbuildPath))
|
|
{
|
|
foreach (var project in nativeProjects)
|
|
{
|
|
Exec(msbuildPath, project + " /p:Configuration=" + Configuration + ";Platform=Win32");
|
|
Exec(msbuildPath, project + " /p:Configuration=" + Configuration + ";Platform=x64");
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
if (i == msbuildVersions.Length - 1)
|
|
{
|
|
Log.Warn("msbuild version 14 or 12 not found. Please ensure you have the VS 2015 or VS 2013 C++ SDK installed.");
|
|
Environment.Exit(1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
copy sourceDir='${Path.GetDirectoryName(project)}' include='bin/**/' outputDir='${Path.Combine(BUILD_DIR, Path.GetFileNameWithoutExtension(project))}' overwrite='${true}' each='var project in nativeProjects'
|
|
|
|
|
|
#nuget-install target='install' description='Install NuGet packages to local repo'
|
|
kpm-publish sourcePackagesDir='${BUILD_DIR}' targetPackagesDir='${E("PACKAGES_PUBLISH_DIR")}'
|
|
nuget-resilient-publish sourcePackagesDir='${BUILD_DIR}' nugetFeed='${E("NUGET_PUBLISH_FEED")}' if='!string.IsNullOrEmpty(E("NUGET_PUBLISH_FEED"))'
|
|
|
|
#xunit-test target='test' if='Directory.Exists("test")'
|
|
k-test each='var projectFile in Files.Include("test/**/project.json")'
|
|
|
|
#build-samples target='test' if='Directory.Exists("samples")'
|
|
kpm-build each='var projectFile in Files.Include("samples/**/project.json")' configuration='${Configuration}'
|
|
|
|
#make-roslyn-fast
|
|
ngen-roslyn
|
|
|
|
#resx
|
|
@{
|
|
foreach (var file in Directory.EnumerateFiles(BASE_DIR, "*.resx", SearchOption.AllDirectories))
|
|
{
|
|
UpdateResx(file);
|
|
}
|
|
}
|
|
|
|
#--quiet
|
|
@{
|
|
E("NUGET3_pack_options"," --quiet");
|
|
E("NUGET3_build_options"," --quiet");
|
|
E("NUGET3_restore_options"," --quiet");
|
|
E("bower_install_options","--quiet");
|
|
E("npm_install_options","--quiet");
|
|
}
|
|
|
|
#stylecop if='Directory.Exists("src")'
|
|
stylecop-setup
|
|
stylecop-run each='var projectFile in Files.Include("src/**/project.json")'
|
|
|
|
functions @{
|
|
string E(string key) { return Environment.GetEnvironmentVariable(key); }
|
|
void E(string key, string value) { Environment.SetEnvironmentVariable(key, value); }
|
|
IEnumerable<string> GetDirectoriesContaining(string path, string searchPattern)
|
|
{
|
|
var sep = Path.DirectorySeparatorChar;
|
|
// Don't include directories that are children of a node_modules or bower_components directory
|
|
return Directory.GetFiles(path, searchPattern, SearchOption.AllDirectories)
|
|
.Where(p => p.IndexOf(sep + "node_modules" + sep) < 0 &&
|
|
p.IndexOf(sep + "bower_components" + sep) < 0)
|
|
.Select(p => Path.GetDirectoryName(p))
|
|
.Distinct();
|
|
}
|
|
bool TestCommand(string program, string commandline)
|
|
{
|
|
// Tests whether a given command succeeds at the command line.
|
|
// Useful for testing whether a given command is installed and on the path, e.g. node
|
|
ProcessStartInfo processStartInfo;
|
|
|
|
if(!IsLinux)
|
|
{
|
|
processStartInfo = new ProcessStartInfo {
|
|
UseShellExecute = false,
|
|
FileName = "cmd",
|
|
Arguments = "/C " + program + " " + commandline,
|
|
};
|
|
} else
|
|
{
|
|
processStartInfo = new ProcessStartInfo {
|
|
UseShellExecute = false,
|
|
FileName = program,
|
|
Arguments = commandline,
|
|
};
|
|
}
|
|
try
|
|
{
|
|
Log.Info(string.Format("Testing for command: {0} {1}", program, commandline));
|
|
var process = Process.Start(processStartInfo);
|
|
process.WaitForExit();
|
|
if (process.ExitCode == 0)
|
|
{
|
|
Log.Info(" command found (0 exit code)");
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
Log.Warn(" command not found (non-0 exit code)");
|
|
return false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Warn(" command exception: " + ex.ToString());
|
|
Log.Warn(" command not found");
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
macro name='Exec' program='string' commandline='string'
|
|
exec
|
|
|
|
macro name="UpdateResx" resxFile='string'
|
|
k-generate-resx
|