Repository navigation
Expand file tree
/
Copy pathcakefile.cake
More file actions
69 lines (60 loc) · 2.42 KB
/
Copy pathcakefile.cake
File metadata and controls
69 lines (60 loc) · 2.42 KB
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
#load "nuget:?package=Rocket.Surgery.Cake.Library&version=0.10.0";
Task("Default")
.IsDependentOn("PinVersion")
.IsDependentOn("dotnetcore")
.IsDependentOn("TestScripts")
;
Task("PinVersion")
.WithCriteria(!BuildSystem.IsLocalBuild)
.Does(() => {
foreach (var angel in GetFiles("./src/**/*.cake")) {
PinVersion(angel, GitVer.SemVer);
}
});
void PinVersion(FilePath file, string version) {
var content = System.IO.File.ReadAllText(file.FullPath);
if (content.IndexOf("{version}") > -1) {
System.IO.File.WriteAllText(file.FullPath, content.Replace("{version}", version));
}
}
Task("TestScripts")
.IsDependentOn("dotnetcore build")
.WithCriteria(false)
// .WithCriteria(BuildSystem.IsLocalBuild)
.DoesForEach(GetFiles("src/**/*.cake"), (sourceFile) => {
var testFolder = Artifacts.Combine("testfolder");
CleanDirectory(testFolder);
EnsureDirectoryExists(testFolder);
Information(sourceFile);
var nugetConfig = testFolder.CombineWithFilePath("NuGet.config");
CopyFile("./NuGet.config", nugetConfig);
// Todo update this to be cross platform
NuGetAddSource(
"testlocation",
ArtifactDirectoryPath("nuget").MakeAbsolute(Context.Environment).FullPath.Replace("/", "\\"),
new NuGetSourcesSettings() {
ConfigFile = nugetConfig,
});
var testFile = testFolder.CombineWithFilePath(sourceFile.GetFilename());
CopyFile(sourceFile, testFile);
PinVersion(testFile, GitVer.SemVer);
CopyFile("src/Cake.Scripts/tools/tools.cake", testFolder.CombineWithFilePath("tools.cake"));
PinVersion(testFolder.CombineWithFilePath("tools.cake"), GitVer.SemVer);
try {
CakeExecuteScript(testFolder.CombineWithFilePath(sourceFile.GetFilename()), new CakeSettings() {
WorkingDirectory = testFolder
});
} catch {
foreach (var angel in GetFiles(testFolder.FullPath + "/**/*.cake")) {
PinVersion(angel, GitVer.SemVer);
}
CakeExecuteScript(testFolder.CombineWithFilePath(sourceFile.GetFilename()), new CakeSettings() {
WorkingDirectory = testFolder
});
}
})
.Does(() => {
var testFolder = Artifacts.Combine("testfolder");
CleanDirectory(testFolder);
});
RunTarget(Target);