-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathbuild.cake
123 lines (107 loc) · 3.15 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
var target = Argument("target", "PushNuGet");
var packageFeedUrl = "https://skynetcode.pkgs.visualstudio.com/_packaging/skynetpackagefeed/nuget/v3/index.json";
var solutionFilePath = "./JwtAuthenticationHelper.sln";
var coreLibPath = "./src/JwtHelper.Core/JwtHelper.Core.csproj";
var cookieExtensionLibPath = "./src/JwtHelper.ServiceCollection.Extensions.Cookies/JwtHelper.ServiceCollection.Extensions.Cookies.csproj";
var jwtExtensionLibPath = "./src/JwtHelper.ServiceCollection.Extensions.JwtBearer/JwtHelper.ServiceCollection.Extensions.JwtBearer.csproj";
Setup(ctx=>
{
var buildNumber = EnvironmentVariable("BUILD_BUILDNUMBER");
if(!string.IsNullOrWhiteSpace(buildNumber))
{
Information($"The build number was {buildNumber}");
}
SetUpNuget();
});
void SetUpNuget()
{
Information("Setting up Nuget feed...");
var feed = new
{
Name = "SkynetNuget",
Source = packageFeedUrl
};
if (!DotNetNuGetHasSource(name:feed.Name))
{
Warning($"Nuget feed {feed.Source} not found, adding...");
var nugetSourceSettings = new DotNetNuGetSourceSettings
{
Source = feed.Source,
UserName = "skynetcode",
Password = EnvironmentVariable("SYSTEM_ACCESSTOKEN"),
StorePasswordInClearText = true
};
try
{
DotNetNuGetAddSource(
name:feed.Name,
settings:nugetSourceSettings);
}
catch(Exception ex)
{
Warning(ex.Message);
}
}
else
{
Information($"Nuget feed {feed.Name} already exists!");
}
}
Task("Restore")
.Does(() => {
Information("Restoring nuget packages...");
DotNetRestore(solutionFilePath);
});
Task("Build")
.IsDependentOn("Restore")
.Does(()=>{
var config = new DotNetCoreBuildSettings
{
Configuration = "Release"
};
Information("Building solution...");
DotNetBuild(solutionFilePath, config);
});
Task("Verify-PR")
.IsDependentOn("Build")
.Does(()=> {
var config = new DotNetCoreTestSettings
{
NoBuild = true,
Configuration = "Release"
};
DotNetTest(solutionFilePath, config);
});
Task("Pack")
.IsDependentOn("Build")
.Does(()=>{
var settings = new DotNetCorePackSettings
{
Configuration = "Release",
OutputDirectory = "./artifacts/",
NoBuild = true,
NoRestore = true
};
Information("Packing binaries...");
DotNetPack(coreLibPath, settings);
DotNetPack(cookieExtensionLibPath, settings);
DotNetPack(jwtExtensionLibPath, settings);
});
Task("PushToNuGet")
.IsDependentOn("Pack")
.Does(()=>{
Information($"Publishing to {packageFeedUrl}");
var files = GetFiles("./artifacts/**/*.*.nupkg");
var settings = new DotNetNuGetPushSettings
{
Source = "https://skynetcode.pkgs.visualstudio.com/_packaging/skynetpackagefeed/nuget/v3/index.json",
ApiKey = "gibberish",
SkipDuplicate = true
};
foreach(var file in files)
{
Information("File: {0}", file);
DotNetNuGetPush(file.FullPath, settings);
}
});
RunTarget(target);