145 lines
4.2 KiB
Plaintext
145 lines
4.2 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="FileWatcher"
|
|
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='Release'
|
|
|
|
@{
|
|
E("K_BUILD_VERSION", BuildNumber);
|
|
}
|
|
|
|
#repo-initialize target='initialize'
|
|
k-restore
|
|
k-generate-projects solutionPath='${BASE_DIR}' if='!IsMono'
|
|
|
|
#target-dir-clean target='clean'
|
|
directory delete="${TARGET_DIR}"
|
|
|
|
#build-clean target='clean'
|
|
k-clean each='var projectFile in Files.Include("src/**/project.json")'
|
|
|
|
#build-compile target='compile'
|
|
k-build each='var projectFile in Files.Include("src/**/project.json")'
|
|
@{
|
|
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'
|
|
var programFilesX86 = '${Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)}'
|
|
var msbuild = '${Path.Combine(programFilesX86, "MSBuild", "12.0", "Bin", "MSBuild.exe")}'
|
|
var nativeProjects ='${Files.Include(Path.Combine(BASE_DIR, "src", "**", "*.vcxproj"))}'
|
|
|
|
@{
|
|
if(!File.Exists(msbuild))
|
|
{
|
|
Log.Warn("msbuild version 12 not found. Please ensure you have the VS 2013 C++ SDK installed.");
|
|
Environment.Exit(1);
|
|
}
|
|
else
|
|
{
|
|
foreach (var project in nativeProjects)
|
|
{
|
|
Exec(msbuild, project + " /p:Configuration=" + Configuration + ";Platform=Win32");
|
|
Exec(msbuild, project + " /p:Configuration=" + Configuration + ";Platform=x64");
|
|
}
|
|
}
|
|
}
|
|
|
|
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='Copy NuGet packages to local repo'
|
|
nuget-local-publish sourcePackagesDir='${BUILD_DIR}'
|
|
|
|
#xunit-test target='test' if='Directory.Exists("test")'
|
|
k-test each='var projectFile in Files.Include("test/**/project.json")'
|
|
|
|
#make-roslyn-fast
|
|
ngen-roslyn
|
|
|
|
#resx
|
|
@{
|
|
foreach (var file in Directory.EnumerateFiles(BASE_DIR, "*.resx", SearchOption.AllDirectories))
|
|
{
|
|
UpdateResx(file);
|
|
}
|
|
}
|
|
|
|
#watch
|
|
@{
|
|
var watcher = new FileWatcher(BASE_DIR);
|
|
|
|
foreach (var file in Directory.EnumerateFiles(BASE_DIR, "*.json", SearchOption.AllDirectories))
|
|
{
|
|
watcher.WatchFile(file);
|
|
}
|
|
|
|
foreach (var file in Directory.EnumerateFiles(BASE_DIR, "*.cs", SearchOption.AllDirectories))
|
|
{
|
|
watcher.WatchFile(file);
|
|
}
|
|
|
|
foreach (var file in Directory.EnumerateFiles(BASE_DIR, "*.resx", SearchOption.AllDirectories))
|
|
{
|
|
watcher.WatchFile(file);
|
|
}
|
|
|
|
foreach (var dir in Directory.EnumerateDirectories(BASE_DIR, "*.*", SearchOption.AllDirectories))
|
|
{
|
|
watcher.WatchDirectory(dir, ".cs");
|
|
watcher.WatchDirectory(dir, ".json");
|
|
}
|
|
|
|
watcher.OnChanged += path =>
|
|
{
|
|
Log.Info("Change detected in " + path);
|
|
bool restore = path.EndsWith("project.json");
|
|
|
|
if(path.EndsWith(".resx"))
|
|
{
|
|
UpdateResx(path);
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
UpdateProjects(BASE_DIR, restore);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Warn(ex.Message);
|
|
}
|
|
|
|
Log.Info("Waiting for changes...");
|
|
};
|
|
|
|
Log.Info("Waiting for changes...");
|
|
Console.ReadLine();
|
|
}
|
|
|
|
functions @{
|
|
string E(string key) { return Environment.GetEnvironmentVariable(key); }
|
|
void E(string key, string value) { Environment.SetEnvironmentVariable(key, value); }
|
|
}
|
|
|
|
macro name='UpdateProjects' basePath='string' restore='bool'
|
|
k command='restore' prefetch='${false}' if='restore'
|
|
k-generate-projects solutionPath='${basePath}' skipNet45='${!restore}'
|
|
|
|
macro name='Exec' program='string' commandline='string'
|
|
exec
|
|
|
|
macro name="UpdateResx" resxFile='string'
|
|
k-generate-resx
|