Skip to content

Commit 98e31bb

Browse files
committed
added GitVersion to build.cake
1 parent c774e1d commit 98e31bb

File tree

2 files changed

+44
-27
lines changed

2 files changed

+44
-27
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,5 @@ paket-files/
258258

259259
# Python Tools for Visual Studio (PTVS)
260260
__pycache__/
261-
*.pyc
261+
*.pyc
262+
/tools

build.cake

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#tool "nuget:?package=GitVersion.CommandLine"
2+
13
//////////////////////////////////////////////////////////////////////
24
// ARGUMENTS
35
//////////////////////////////////////////////////////////////////////
@@ -14,60 +16,74 @@ var buildDir = Directory("./artifacts") + Directory(configuration);
1416
var solutionFile = File("./src/FluentAssertions.BestPractices.sln");
1517
var testCsproj = File("./src/FluentAssertions.BestPractices.Tests/FluentAssertions.BestPractices.Tests.csproj");
1618
var nuspecFile = File("./src/FluentAssertions.BestPractices/FluentAssertions.BestPractices.nuspec");
19+
GitVersion gitVersion;
1720

1821
//////////////////////////////////////////////////////////////////////
1922
// TASKS
2023
//////////////////////////////////////////////////////////////////////
2124

25+
Task("GitVersion")
26+
.Does(() =>
27+
{
28+
gitVersion = GitVersion(new GitVersionSettings
29+
{
30+
UpdateAssemblyInfo = true
31+
});
32+
});
33+
2234
Task("Clean")
2335
.Does(() =>
24-
{
25-
CleanDirectory(buildDir);
26-
});
36+
{
37+
CleanDirectory(buildDir);
38+
});
2739

2840
Task("Restore-NuGet-Packages")
2941
.IsDependentOn("Clean")
3042
.Does(() =>
31-
{
32-
DotNetCoreRestore(solutionFile);
33-
});
43+
{
44+
DotNetCoreRestore(solutionFile);
45+
});
3446

3547
Task("Build")
3648
.IsDependentOn("Restore-NuGet-Packages")
3749
.Does(() =>
38-
{
39-
DotNetCoreBuild(solutionFile, new DotNetCoreBuildSettings
40-
{
41-
Configuration = configuration,
42-
OutputDirectory = buildDir
43-
});
44-
});
50+
{
51+
DotNetCoreBuild(solutionFile, new DotNetCoreBuildSettings
52+
{
53+
Configuration = configuration,
54+
OutputDirectory = buildDir
55+
});
56+
});
4557

4658
Task("Run-Unit-Tests")
47-
.IsDependentOn("Build")
59+
.IsDependentOn("Build")
4860
.Does(() =>
49-
{
50-
DotNetCoreTest(testCsproj, new DotNetCoreTestSettings
51-
{
52-
Filter = "TestCategory=Completed",
53-
Configuration = configuration
54-
});
55-
});
61+
{
62+
DotNetCoreTest(testCsproj, new DotNetCoreTestSettings
63+
{
64+
Filter = "TestCategory=Completed",
65+
Configuration = configuration
66+
});
67+
});
5668

5769
Task("Pack")
58-
.Does(() =>
70+
.IsDependentOn("GitVersion")
71+
.Does(() =>
5972
{
60-
var nuGetPackSettings = new NuGetPackSettings {
61-
OutputDirectory = buildDir
62-
};
63-
NuGetPack(nuspecFile, nuGetPackSettings);
73+
var nuGetPackSettings = new NuGetPackSettings
74+
{
75+
OutputDirectory = buildDir,
76+
Version = gitVersion.NuGetVersionV2
77+
};
78+
NuGetPack(nuspecFile, nuGetPackSettings);
6479
});
6580

6681
//////////////////////////////////////////////////////////////////////
6782
// TASK TARGETS
6883
//////////////////////////////////////////////////////////////////////
6984

7085
Task("Default")
86+
.IsDependentOn("GitVersion")
7187
.IsDependentOn("Build")
7288
.IsDependentOn("Run-Unit-Tests")
7389
.IsDependentOn("Pack");

0 commit comments

Comments
 (0)