Skip to content

Commit 16a5c25

Browse files
committed
Merge branch 'devlead-feature/GH-54' into develop
* devlead-feature/GH-54: Added CI configuration files Added Cake build script & boostrappers Added MSBuild solution/project & ported to .NET Core
2 parents c51f9dc + 4928423 commit 16a5c25

17 files changed

Lines changed: 620 additions & 72 deletions

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
/bin
22
/src/LitJson/AssemblyInfo.cs
33
/website
4+
[Oo]bj/
5+
[Bb]in/
6+
.vscode/
7+
[Tt]ools/*
8+
![Tt]ools/packages.config
9+
[Aa]rtifacts/
10+
.[Dd]otnet/

.travis.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
language: csharp
2+
os:
3+
- osx
4+
- linux
5+
6+
# Ubuntu 14.04
7+
sudo: required
8+
dist: trusty
9+
10+
# OS X 10.12
11+
osx_image: xcode9.2
12+
13+
mono:
14+
- 4.4.2
15+
16+
dotnet: 2.1.3
17+
18+
before_install:
19+
- git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags
20+
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
21+
- git fetch origin
22+
23+
script:
24+
- ./build.sh --target=Test

LitJSON.sln

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26124.0
5+
MinimumVisualStudioVersion = 15.0.26124.0
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LitJSON", "src\LitJson\LitJSON.csproj", "{CFBC33D5-BB2D-4F22-B157-0862C4A77039}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LitJSON.Tests", "test\LitJSON.Tests.csproj", "{E031C1B4-CD87-475E-9283-4571435C65DB}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Debug|x64 = Debug|x64
14+
Debug|x86 = Debug|x86
15+
Release|Any CPU = Release|Any CPU
16+
Release|x64 = Release|x64
17+
Release|x86 = Release|x86
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
23+
{CFBC33D5-BB2D-4F22-B157-0862C4A77039}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24+
{CFBC33D5-BB2D-4F22-B157-0862C4A77039}.Debug|Any CPU.Build.0 = Debug|Any CPU
25+
{CFBC33D5-BB2D-4F22-B157-0862C4A77039}.Debug|x64.ActiveCfg = Debug|x64
26+
{CFBC33D5-BB2D-4F22-B157-0862C4A77039}.Debug|x64.Build.0 = Debug|x64
27+
{CFBC33D5-BB2D-4F22-B157-0862C4A77039}.Debug|x86.ActiveCfg = Debug|x86
28+
{CFBC33D5-BB2D-4F22-B157-0862C4A77039}.Debug|x86.Build.0 = Debug|x86
29+
{CFBC33D5-BB2D-4F22-B157-0862C4A77039}.Release|Any CPU.ActiveCfg = Release|Any CPU
30+
{CFBC33D5-BB2D-4F22-B157-0862C4A77039}.Release|Any CPU.Build.0 = Release|Any CPU
31+
{CFBC33D5-BB2D-4F22-B157-0862C4A77039}.Release|x64.ActiveCfg = Release|x64
32+
{CFBC33D5-BB2D-4F22-B157-0862C4A77039}.Release|x64.Build.0 = Release|x64
33+
{CFBC33D5-BB2D-4F22-B157-0862C4A77039}.Release|x86.ActiveCfg = Release|x86
34+
{CFBC33D5-BB2D-4F22-B157-0862C4A77039}.Release|x86.Build.0 = Release|x86
35+
{E031C1B4-CD87-475E-9283-4571435C65DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36+
{E031C1B4-CD87-475E-9283-4571435C65DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
37+
{E031C1B4-CD87-475E-9283-4571435C65DB}.Debug|x64.ActiveCfg = Debug|x64
38+
{E031C1B4-CD87-475E-9283-4571435C65DB}.Debug|x64.Build.0 = Debug|x64
39+
{E031C1B4-CD87-475E-9283-4571435C65DB}.Debug|x86.ActiveCfg = Debug|x86
40+
{E031C1B4-CD87-475E-9283-4571435C65DB}.Debug|x86.Build.0 = Debug|x86
41+
{E031C1B4-CD87-475E-9283-4571435C65DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
42+
{E031C1B4-CD87-475E-9283-4571435C65DB}.Release|Any CPU.Build.0 = Release|Any CPU
43+
{E031C1B4-CD87-475E-9283-4571435C65DB}.Release|x64.ActiveCfg = Release|x64
44+
{E031C1B4-CD87-475E-9283-4571435C65DB}.Release|x64.Build.0 = Release|x64
45+
{E031C1B4-CD87-475E-9283-4571435C65DB}.Release|x86.ActiveCfg = Release|x86
46+
{E031C1B4-CD87-475E-9283-4571435C65DB}.Release|x86.Build.0 = Release|x86
47+
EndGlobalSection
48+
EndGlobal

appveyor.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
version: 1.0.{build}
2-
image: Visual Studio 2017
3-
install:
4-
- ps: >-
5-
choco install make
1+
# Operating system (build VM template)
2+
os: Visual Studio 2017
63

7-
8-
mkdir bin
4+
# Build script
95
build_script:
10-
- cmd: >-
11-
cd build/make
6+
- ps: .\build.ps1 --target="AppVeyor" --verbosity=Verbose
127

13-
make CSC='"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Roslyn\csc.exe"'
8+
# Tests
149
test: off

build.cake

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
2+
#tool "nuget:https://api.nuget.org/v3/index.json?package=GitVersion.CommandLine&version=3.6.2"
3+
#tool nuget:?package=NUnit.ConsoleRunner&version=3.4.0
4+
5+
///////////////////////////////////////////////////////////////////////////////
6+
// ARGUMENTS
7+
///////////////////////////////////////////////////////////////////////////////
8+
9+
var target = Argument("target", "Default");
10+
var configuration = Argument("configuration", "Release");
11+
12+
//////////////////////////////////////////////////////////////////////
13+
// PARAMETERS
14+
//////////////////////////////////////////////////////////////////////
15+
16+
DotNetCoreMSBuildSettings msBuildSettings = null;
17+
string version = null,
18+
semVersion = null,
19+
milestone = null;
20+
21+
///////////////////////////////////////////////////////////////////////////////
22+
// SETUP / TEARDOWN
23+
///////////////////////////////////////////////////////////////////////////////
24+
25+
Setup(ctx =>
26+
{
27+
Information("Calculating Semantic Version");
28+
if (!BuildSystem.IsLocalBuild)
29+
{
30+
GitVersion(new GitVersionSettings{
31+
OutputType = GitVersionOutput.BuildServer
32+
});
33+
}
34+
35+
CopyFile("./src/LitJson/AssemblyInfo.cs.in", "./src/LitJson/AssemblyInfo.cs");
36+
37+
GitVersion assertedVersions = GitVersion(new GitVersionSettings
38+
{
39+
UpdateAssemblyInfoFilePath = "./src/LitJson/AssemblyInfo.cs",
40+
UpdateAssemblyInfo = true,
41+
OutputType = GitVersionOutput.Json,
42+
});
43+
44+
version = assertedVersions.MajorMinorPatch;
45+
semVersion = assertedVersions.LegacySemVerPadded;
46+
milestone = string.Concat("v", version);
47+
48+
Information("Calculated Semantic Version: {0}", semVersion);
49+
50+
msBuildSettings = new DotNetCoreMSBuildSettings()
51+
.WithProperty("Version", semVersion)
52+
.WithProperty("AssemblyVersion", version)
53+
.WithProperty("FileVersion", version);
54+
55+
if(!IsRunningOnWindows())
56+
{
57+
var frameworkPathOverride = new FilePath(typeof(object).Assembly.Location).GetDirectory().FullPath + "/";
58+
59+
// Use FrameworkPathOverride when not running on Windows.
60+
Information("Build will use FrameworkPathOverride={0} since not building on Windows.", frameworkPathOverride);
61+
msBuildSettings.WithProperty("FrameworkPathOverride", frameworkPathOverride);
62+
}
63+
64+
// Executed BEFORE the first task.
65+
Information("Running tasks...");
66+
});
67+
68+
Teardown(ctx =>
69+
{
70+
// Executed AFTER the last task.
71+
Information("Finished running tasks.");
72+
});
73+
74+
///////////////////////////////////////////////////////////////////////////////
75+
// TASKS
76+
///////////////////////////////////////////////////////////////////////////////
77+
78+
Task("Clean")
79+
.Does(() => {
80+
CleanDirectories(
81+
new[] {
82+
"./src/bin",
83+
"./test/bin",
84+
"./src/obj",
85+
"./test/obj",
86+
"./artifacts/nuget"
87+
}
88+
);
89+
});
90+
91+
Task("Restore")
92+
.IsDependentOn("Clean")
93+
.Does(() => {
94+
DotNetCoreRestore("./LitJSON.sln",
95+
new DotNetCoreRestoreSettings { MSBuildSettings = msBuildSettings }
96+
);
97+
});
98+
99+
Task("Build")
100+
.IsDependentOn("Restore")
101+
.Does(() => {
102+
DotNetCoreBuild("./LitJSON.sln",
103+
new DotNetCoreBuildSettings {
104+
Configuration = configuration,
105+
MSBuildSettings = msBuildSettings
106+
}
107+
);
108+
});
109+
110+
Task("Test")
111+
.IsDependentOn("Build")
112+
.Does(() => {
113+
DotNetCoreTest("./test/LitJSON.Tests.csproj",
114+
new DotNetCoreTestSettings {
115+
Configuration = configuration,
116+
Framework = "netcoreapp2.0",
117+
NoBuild = true
118+
}
119+
);
120+
121+
NUnit3("./test/**/bin/" + configuration + "/net45/*.Tests.dll", new NUnit3Settings {
122+
NoResults = true
123+
});
124+
});
125+
126+
Task("Package")
127+
.IsDependentOn("Test")
128+
.Does(() => {
129+
DotNetCorePack("./src/LitJSON/LitJSON.csproj",
130+
new DotNetCorePackSettings {
131+
Configuration = configuration,
132+
NoBuild = true,
133+
IncludeSymbols = true,
134+
OutputDirectory = "./artifacts/nuget",
135+
MSBuildSettings = msBuildSettings
136+
}
137+
);
138+
});
139+
140+
Task("Upload-AppVeyor-Artifacts")
141+
.IsDependentOn("Package")
142+
.WithCriteria(AppVeyor.IsRunningOnAppVeyor)
143+
.Does(() => {
144+
145+
foreach(var artifact in GetFiles("./artifacts/**/*.*"))
146+
{
147+
AppVeyor.UploadArtifact(artifact);
148+
}
149+
});
150+
151+
Task("Publish-MyGet")
152+
.IsDependentOn("Package")
153+
.WithCriteria((AppVeyor.IsRunningOnAppVeyor && !AppVeyor.Environment.PullRequest.IsPullRequest)
154+
|| StringComparer.OrdinalIgnoreCase.Equals(target, "Publish-MyGet"))
155+
.Does(() => {
156+
157+
// Resolve the API key.
158+
var apiKey = EnvironmentVariable("MYGET_API_KEY");
159+
if(string.IsNullOrEmpty(apiKey)) {
160+
throw new InvalidOperationException("Could not resolve MyGet API key.");
161+
}
162+
163+
// Resolve the API url.
164+
var apiUrl = EnvironmentVariable("MYGET_API_URL");
165+
if(string.IsNullOrEmpty(apiUrl)) {
166+
throw new InvalidOperationException("Could not resolve MyGet API url.");
167+
}
168+
169+
foreach(var package in (GetFiles("./artifacts/nuget/*.nupkg") - GetFiles("./artifacts/nuget/*.symbols.nupkg")))
170+
{
171+
DotNetCoreNuGetPush(package.FullPath,
172+
new DotNetCoreNuGetPushSettings {
173+
ApiKey = apiKey,
174+
Source = apiUrl
175+
}
176+
);
177+
}
178+
});
179+
180+
Task("Publish-NuGet")
181+
.IsDependentOn("Package")
182+
.WithCriteria((AppVeyor.IsRunningOnAppVeyor && AppVeyor.Environment.Repository.Tag.IsTag && !AppVeyor.Environment.PullRequest.IsPullRequest)
183+
|| StringComparer.OrdinalIgnoreCase.Equals(target, "Publish-NuGet"))
184+
.Does(() => {
185+
186+
// Resolve the API key.
187+
var apiKey = EnvironmentVariable("NUGET_API_KEY");
188+
if(string.IsNullOrEmpty(apiKey)) {
189+
throw new InvalidOperationException("Could not resolve MyGet API key.");
190+
}
191+
192+
// Resolve the API url.
193+
var apiUrl = EnvironmentVariable("NUGET_API_URL");
194+
if(string.IsNullOrEmpty(apiUrl)) {
195+
throw new InvalidOperationException("Could not resolve MyGet API url.");
196+
}
197+
198+
foreach(var package in (GetFiles("./artifacts/nuget/*.nupkg") - GetFiles("./artifacts/nuget/*.symbols.nupkg")))
199+
{
200+
DotNetCoreNuGetPush(package.FullPath,
201+
new DotNetCoreNuGetPushSettings {
202+
ApiKey = apiKey,
203+
Source = apiUrl
204+
}
205+
);
206+
}
207+
});
208+
209+
Task("AppVeyor")
210+
.IsDependentOn("Upload-AppVeyor-Artifacts")
211+
.IsDependentOn("Publish-MyGet")
212+
.IsDependentOn("Publish-NuGet");
213+
214+
Task("Default")
215+
.IsDependentOn("Package");
216+
217+
RunTarget(target);

0 commit comments

Comments
 (0)