-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnuspecandpush.cake
55 lines (49 loc) · 1.67 KB
/
nuspecandpush.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
var isLocalBuild = !AppVeyor.IsRunningOnAppVeyor;
var isPullRequest = AppVeyor.Environment.PullRequest.IsPullRequest;
var version = "0.0.0.1";
var semVersion = isLocalBuild ? version : (version + string.Concat("-build-", AppVeyor.Environment.Build.Number));
var assemblyId = "SweNug20150122";
var binDir = string.Format("./src/{0}/bin/{1}", assemblyId, configuration);
var nugetRoot = "./nuget/";
var nuGetPackSettings = new NuGetPackSettings {
Id = assemblyId,
Version = semVersion,
BasePath = binDir,
OutputDirectory = nugetRoot
};
Task("Create-NuGet-Package")
.IsDependentOn("Build")
.Does(() =>
{
if (!Directory.Exists(nugetRoot))
{
CreateDirectory(nugetRoot);
}
NuGetPack(
string.Format("./nuspec/{0}.nuspec", assemblyId),
nuGetPackSettings
);
});
Task("Publish-MyGet")
.IsDependentOn("Create-NuGet-Package")
.WithCriteria(() => !isLocalBuild)
.WithCriteria(() => !isPullRequest)
.Does(() =>
{
// Resolve the API key.
var apiKey = EnvironmentVariable("MYGET_API_KEY");
if(string.IsNullOrEmpty(apiKey)) {
throw new InvalidOperationException("Could not resolve MyGet API key.");
}
var source = EnvironmentVariable("MYGET_SOURCE");
if(string.IsNullOrEmpty(apiKey)) {
throw new InvalidOperationException("Could not resolve MyGet source.");
}
// Get the path to the package.
var package = nugetRoot + assemblyId + semVersion + ".nupkg";
// Push the package.
NuGetPush(package, new NuGetPushSettings {
Source = source,
ApiKey = apiKey
});
});