-
-
Notifications
You must be signed in to change notification settings - Fork 70
/
build.cake
132 lines (114 loc) · 4.79 KB
/
build.cake
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#tool "nuget:?package=GitVersion.CommandLine"
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var outputDir = "./artifacts/";
var isAppVeyor = BuildSystem.IsRunningOnAppVeyor;
var isWindows = IsRunningOnWindows();
// libs come here
var libs = new List<string>{
"./src/NetCoreKit.Utils/NetCoreKit.Utils.csproj",
"./src/NetCoreKit.Domain/NetCoreKit.Domain.csproj",
"./src/NetCoreKit.Infrastructure/NetCoreKit.Infrastructure.csproj",
"./src/NetCoreKit.Infrastructure.AspNetCore/NetCoreKit.Infrastructure.AspNetCore.csproj",
"./src/NetCoreKit.Infrastructure.AspNetCore.CleanArch/NetCoreKit.Infrastructure.AspNetCore.CleanArch.csproj",
"./src/NetCoreKit.Infrastructure.AspNetCore.OpenApi/NetCoreKit.Infrastructure.AspNetCore.OpenApi.csproj",
"./src/NetCoreKit.Infrastructure.AspNetCore.All/NetCoreKit.Infrastructure.AspNetCore.All.csproj",
"./src/NetCoreKit.Infrastructure.EfCore/NetCoreKit.Infrastructure.EfCore.csproj",
"./src/NetCoreKit.Infrastructure.EfCore.SqlServer/NetCoreKit.Infrastructure.EfCore.SqlServer.csproj",
"./src/NetCoreKit.Infrastructure.EfCore.MySql/NetCoreKit.Infrastructure.EfCore.MySql.csproj",
"./src/NetCoreKit.Infrastructure.Mongo/NetCoreKit.Infrastructure.Mongo.csproj",
"./src/NetCoreKit.Infrastructure.Bus/NetCoreKit.Infrastructure.Bus.csproj",
"./src/NetCoreKit.Infrastructure.Bus.Kafka/NetCoreKit.Infrastructure.Bus.Kafka.csproj",
"./src/NetCoreKit.Infrastructure.Bus.Redis/NetCoreKit.Infrastructure.Bus.Redis.csproj",
"./src/NetCoreKit.Infrastructure.GrpcHost/NetCoreKit.Infrastructure.GrpcHost.csproj",
"./templates/NetCoreKit.RestTemplate.Standard/NetCoreKit.RestTemplate.Standard.csproj",
"./templates/NetCoreKit.RestTemplate.EfCore/NetCoreKit.RestTemplate.EfCore.csproj",
"./templates/NetCoreKit.RestTemplate.MongoDb/NetCoreKit.RestTemplate.MongoDb.csproj",
"./templates/NetCoreKit.GrpcTemplate.Standard/NetCoreKit.GrpcTemplate.Standard.csproj",
"./templates/NetCoreKit.GrpcTemplate.EfCore/NetCoreKit.GrpcTemplate.EfCore.csproj",
"./templates/NetCoreKit.GrpcTemplate.MongoDb/NetCoreKit.GrpcTemplate.MongoDb.csproj"
};
Task("Clean")
.Does(() => {
if (DirectoryExists(outputDir))
{
DeleteDirectory(outputDir, recursive:true);
}
});
Task("Restore")
.Does(() => {
DotNetCoreRestore("./netcorekit.sln", new DotNetCoreRestoreSettings{
Verbosity = DotNetCoreVerbosity.Minimal,
});
});
GitVersion versionInfo = null;
DotNetCoreMSBuildSettings msBuildSettings = null;
Task("UpdateVersionInfo")
.IsDependentOn("Restore")
.Does(() =>
{
var tag = AppVeyor.Environment.Repository.Tag.Name;
AppVeyor.UpdateBuildVersion(tag);
});
Task("Version")
.IsDependentOn("Restore")
.Does(() => {
GitVersion(new GitVersionSettings{
UpdateAssemblyInfo = false,
OutputType = GitVersionOutput.BuildServer
});
versionInfo = GitVersion(new GitVersionSettings{ OutputType = GitVersionOutput.Json });
Information(versionInfo);
msBuildSettings = new DotNetCoreMSBuildSettings()
.WithProperty("Version", versionInfo.Major + "." + versionInfo.Minor + "." + versionInfo.BuildMetaData)
.WithProperty("AssemblyVersion", versionInfo.AssemblySemVer)
.WithProperty("FileVersion", versionInfo.AssemblySemVer);
});
Task("Build")
.IsDependentOn("Clean")
.IsDependentOn("Version")
.IsDependentOn("Restore")
.Does(() => {
DotNetCoreBuild("./netcorekit.sln", new DotNetCoreBuildSettings()
{
Configuration = configuration,
MSBuildSettings = msBuildSettings
});
});
Task("Package")
.IsDependentOn("Build")
.Does(() => {
foreach (var lib in libs)
DotNetCorePack(lib, new DotNetCorePackSettings
{
Configuration = configuration,
OutputDirectory = outputDir,
MSBuildSettings = msBuildSettings
});
if (!isWindows) return;
if (isAppVeyor)
{
foreach (var file in GetFiles(outputDir + "**/*"))
AppVeyor.UploadArtifact(file.FullPath);
}
});
Task("DeployNuget")
.IsDependentOn("Package")
.Does(() =>
{
if (isAppVeyor)
{
foreach (var file in GetFiles(outputDir + "**/*.nupkg")) {
Information(file.ToString());
NuGetPush(
file,
new NuGetPushSettings {
ApiKey = EnvironmentVariable("NuGetApiKey"),
Source = "https://www.nuget.org/api/v2/package"
});
}
}
});
Task("Default")
.IsDependentOn("DeployNuget");
RunTarget(target);