/
Nake.csx
89 lines (70 loc) · 2.44 KB
/
Nake.csx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#r "System.Xml"
#r "System.Xml.Linq"
using Nake;
using Nake.FS;
using Nake.Log;
using Nake.Env;
using Nake.Run;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using System.Diagnostics;
const string RootPath = "$NakeScriptDirectory$";
const string OutputPath = RootPath + @"\Output";
var MSBuildExe = @"$ProgramFiles(x86)$\MSBuild\12.0\Bin\MSBuild.exe";
/// Builds sources in debug mode
[Task] void Default()
{
Build();
}
/// Wipeout all build output and temporary build files
[Step] void Clean(string path = OutputPath)
{
Delete(@"{path}\*.*|-:*.vshost.exe");
RemoveDir(@"**\bin|**\obj|{path}\*|-:*.vshost.exe");
}
/// Builds sources using specified configuration and output path
[Step] void Build(string config = "Debug", string outDir = OutputPath)
{
Clean(outDir);
Exec(MSBuildExe,
"Nake.sln /p:Configuration={config};OutDir={outDir};ReferencePath={outDir} /m");
}
/// Runs unit tests
[Step] void Test(string outputPath = OutputPath)
{
Build("Debug", outputPath);
var tests = new FileSet{@"{outputPath}\*.Tests.dll"}.ToString(" ");
Cmd(@"Packages\NUnit.Runners.2.6.2\tools\nunit-console.exe /framework:net-4.0 /noshadow /nologo {tests}");
}
/// Builds official NuGet package
[Step] void Package()
{
var packagePath = OutputPath + @"\Package";
var releasePath = packagePath + @"\Release";
Test(@"{packagePath}\Debug");
Build("Release", releasePath);
var version = FileVersionInfo
.GetVersionInfo(@"{releasePath}\Nake.exe")
.ProductVersion;
File.WriteAllText(
@"{releasePath}\Nake.bat",
"@ECHO OFF \r\n" +
@"Packages\Nake.{version}\tools\net45\Nake.exe %*"
);
Exec(MSBuildExe,
@"Source\Utility\Utility.shfbproj /p:OutputPath={releasePath};SourcePath={releasePath}");
Cmd(@"Tools\Nuget.exe pack Build\NuGet\Nake.nuspec -Version {version} " +
"-OutputDirectory {packagePath} -BasePath {RootPath} -NoPackageAnalysis");
}
/// Installs dependencies (packages) from NuGet
[Task] void Install()
{
var packagesDir = @"{RootPath}\Packages";
var configs = XElement
.Load(packagesDir + @"\repositories.config")
.Descendants("repository")
.Select(x => x.Attribute("path").Value.Replace("..", RootPath));
foreach (var config in configs)
Cmd(@"Tools\NuGet.exe install {config} -o {packagesDir}");
}