-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.cake
147 lines (130 loc) · 4.08 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#tool "nuget:?package=NuGet.CommandLine&version=6.10.1"
#tool "nuget:?package=7-Zip.CommandLine&version=18.1.0"
#addin "nuget:?package=Cake.MinVer&version=2.0.0"
#addin "nuget:?package=Cake.Args&version=1.0.1"
#addin "nuget:?package=Cake.7zip&version=1.0.4"
var target = ArgumentOrDefault<string>("target") ?? "publish";
var buildVersion = MinVer(s => s.WithTagPrefix("v").WithDefaultPreReleasePhase("preview"));
Task("clean")
.Does(() =>
{
CleanDirectories("./artifact/**");
CleanDirectories("./**/^{bin,obj}");
});
Task("restore")
.IsDependentOn("clean")
.Does(() =>
{
DotNetCoreRestore("./exceldna-unpack.sln", new DotNetCoreRestoreSettings
{
LockedMode = true,
});
NuGetRestore("./test/ExcelDnaUnpack.Tests.ExcelAddIn/ExcelDnaUnpack.Tests.ExcelAddIn.csproj", new NuGetRestoreSettings
{
NoCache = true,
NonInteractive = true,
PackagesDirectory = MakeAbsolute(new DirectoryPath("./packages")),
});
});
Task("build")
.IsDependentOn("restore")
.DoesForEach(new[] { "Debug", "Release" }, (configuration) =>
{
MSBuild("./exceldna-unpack.sln", settings => settings
.SetConfiguration(configuration)
.UseToolVersion(MSBuildToolVersion.VS2019)
.WithTarget("Rebuild")
.SetVersion(buildVersion.Version)
.SetFileVersion(buildVersion.FileVersion)
.SetContinuousIntegrationBuild()
);
});
Task("test")
.IsDependentOn("build")
.Does(() =>
{
var settings = new DotNetCoreTestSettings
{
Configuration = "Release",
NoRestore = true,
NoBuild = true,
};
var projectFiles = GetFiles("./test/**/*.csproj");
foreach (var file in projectFiles)
{
DotNetCoreTest(file.FullPath, settings);
}
});
Task("pack")
.IsDependentOn("test")
.Does(() =>
{
var releaseNotes = $"https://github.com/augustoproiete/exceldna-unpack/releases/tag/v{buildVersion.Version}";
DotNetCorePack("./src/ExcelDnaUnpack/ExcelDnaUnpack.csproj", new DotNetCorePackSettings
{
Configuration = "Release",
NoRestore = true,
NoBuild = true,
IncludeSymbols = true,
IncludeSource = true,
OutputDirectory = "./artifact/nuget",
MSBuildSettings = new DotNetCoreMSBuildSettings
{
Version = buildVersion.Version,
PackageReleaseNotes = releaseNotes,
},
});
});
Task("publish")
.IsDependentOn("pack")
.DoesForEach(new[] { "win7-x64", "win7-x86" }, (runtime) =>
{
DotNetCorePublish("./src/ExcelDnaUnpack/ExcelDnaUnpack.csproj", new DotNetCorePublishSettings
{
Framework = "net5.0",
Runtime = runtime,
Configuration = "Release",
SelfContained = true,
PublishSingleFile = true,
PublishTrimmed = true,
OutputDirectory = $"./artifact/standalone/{runtime}",
MSBuildSettings = new DotNetCoreMSBuildSettings()
.SetVersion(buildVersion.Version)
.WithProperty("IncludeNativeLibrariesForSelfExtract", "true")
});
SevenZip(new SevenZipSettings
{
Command = new AddCommand
{
Files = GetFiles($"./artifact/standalone/{runtime}/exceldna-unpack.*"),
Archive = new FilePath($"./artifact/standalone/exceldna-unpack-{buildVersion.Version}-{runtime}.zip"),
}
});
});
Task("push")
.IsDependentOn("publish")
.Does(() =>
{
var url = EnvironmentVariable("NUGET_URL");
if (string.IsNullOrWhiteSpace(url))
{
Information("No NuGet URL specified. Skipping publishing of NuGet packages");
return;
}
var apiKey = EnvironmentVariable("NUGET_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey))
{
Information("No NuGet API key specified. Skipping publishing of NuGet packages");
return;
}
var nugetPushSettings = new DotNetCoreNuGetPushSettings
{
Source = url,
ApiKey = apiKey,
};
foreach (var nugetPackageFile in GetFiles("./artifact/nuget/*.nupkg"))
{
DotNetCoreNuGetPush(nugetPackageFile.FullPath, nugetPushSettings);
}
});
RunTarget(target);