Skip to content

Commit 46b94be

Browse files
committed
cake integration for aspnetboilerplate#2487
1 parent dd0bff9 commit 46b94be

File tree

7 files changed

+297
-124
lines changed

7 files changed

+297
-124
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,5 @@ src/.vs/config/applicationhost.config
125125
# GitLink
126126
!GitLink.exe
127127
!nuget.exe
128-
!SQLite.Interop.dll
128+
!SQLite.Interop.dll
129+
/tools

Abp.sln

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26730.10
4+
VisualStudioVersion = 15.0.26730.16
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{DFF0464B-5402-4DD6-86F5-2AEC1163B232}"
77
EndProject
@@ -107,8 +107,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Abp.Dapper.Tests", "test\Ab
107107
EndProject
108108
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution-items", "solution-items", "{0A8896A1-EC2E-44D8-BD7E-34D2E46A16CF}"
109109
ProjectSection(SolutionItems) = preProject
110+
.gitattributes = .gitattributes
111+
.gitignore = .gitignore
110112
appveyor.yml = appveyor.yml
113+
build.cake = build.cake
114+
build.ps1 = build.ps1
111115
common.props = common.props
116+
LICENSE = LICENSE
117+
README.md = README.md
112118
EndProjectSection
113119
EndProject
114120
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Abp.HangFire.AspNetCore", "src\Abp.HangFire.AspNetCore\Abp.HangFire.AspNetCore.csproj", "{1CC8525B-3F36-4ED0-BD5A-18DCEA19167E}"
@@ -165,7 +171,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Abp.ZeroCore.SampleApp", "t
165171
EndProject
166172
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Abp.ZeroCore.Tests", "test\Abp.ZeroCore.Tests\Abp.ZeroCore.Tests.csproj", "{0CA8B27D-292C-4D57-AD88-EB0073C68F31}"
167173
EndProject
168-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Abp.Castle.Log4Net.Tests", "test\Abp.Castle.Log4Net.Tests\Abp.Castle.Log4Net.Tests.csproj", "{F6F5F70B-2217-403F-AB87-6DFA9AD6692F}"
174+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Abp.Castle.Log4Net.Tests", "test\Abp.Castle.Log4Net.Tests\Abp.Castle.Log4Net.Tests.csproj", "{F6F5F70B-2217-403F-AB87-6DFA9AD6692F}"
169175
EndProject
170176
Global
171177
GlobalSection(SolutionConfigurationPlatforms) = preSolution

appveyor.yml

+6-49
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,10 @@
1+
version: 1.0.{build}
12
configuration: Release
2-
version: 3.0.0-beta{build}
33
image: Visual Studio 2017
4-
5-
nuget:
6-
disable_publish_on_pr: true
7-
8-
before_build:
9-
- cmd: set PATH=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin;C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin;%PATH%
10-
- cmd: nuget install nuget.commandline -source https://dotnet.myget.org/F/nuget-build -prerelease -excludeversion
11-
- cmd: set PATH=%appveyor_build_folder%\NuGet.CommandLine\tools;%PATH%
12-
- cmd: dotnet.exe restore
13-
14-
after_build:
15-
- ps: >-
16-
$versionSuffix=(Get-Item Env:APPVEYOR_BUILD_NUMBER).Value
17-
18-
Set-Location "nupkg"
19-
20-
.\pack.ps1 -versionSuffix "$versionSuffix"
21-
22-
build:
23-
verbosity: minimal
24-
25-
pull_requests:
4+
pull_requests:
265
do_not_increment_build_number: true
6+
7+
build_script:
8+
- ps: .\build.ps1
279

28-
test:
29-
assemblies:
30-
- test\Abp.Tests\bin\Release\net46\Abp.Tests.dll
31-
- test\Abp.AspNetCore.Tests\bin\Release\net46\Abp.AspNetCore.Tests.dll
32-
- test\Abp.Web.Tests\bin\Release\net46\Abp.Web.Tests.dll
33-
- test\Abp.Web.Common.Tests\bin\Release\net46\Abp.Web.Common.Tests.dll
34-
- test\Abp.Web.Api.Tests\bin\Release\net46\Abp.Web.Api.Tests.dll
35-
- test\Abp.Web.Mvc.Tests\bin\Release\net46\Abp.Web.Mvc.Tests.dll
36-
- test\Abp.AutoMapper.Tests\bin\Release\net46\Abp.AutoMapper.dll
37-
- test\Abp.EntityFramework.Tests\bin\Release\net46\Abp.EntityFramework.Tests.dll
38-
- test\Abp.EntityFramework.GraphDiff.Tests\bin\Release\net46\Abp.EntityFramework.GraphDiff.Tests.dll
39-
- test\Abp.EntityFrameworkCore.Tests\bin\Release\net46\Abp.EntityFrameworkCore.Tests.dll
40-
# - test\Abp.EntityFrameworkCore.Dapper.Tests\bin\Release\netcoreapp1.1\Abp.EntityFrameworkCore.Dapper.Tests.dll
41-
- test\Abp.MemoryDb.Tests\bin\Release\net46\Abp.MemoryDb.Tests.dll
42-
- test\Abp.Quartz.Tests\bin\Release\net46\Abp.Quartz.Tests.dll
43-
- test\Abp.TestBase.Tests\bin\Release\net46\Abp.TestBase.Tests.dll
44-
- test\Abp.TestBase.SampleApplication.Tests\bin\Release\net46\Abp.TestBase.SampleApplication.Tests.dll
45-
# - test\Abp.Dapper.Tests\bin\Release\net46\Abp.Dapper.Tests.dll
46-
# - test\Abp.NHibernate.Tests\bin\Release\net46\Abp.NHibernate.Tests.dll
47-
- test\Abp.Zero.SampleApp.Tests\bin\Release\net452\Abp.Zero.SampleApp.Tests.dll
48-
# - test\Abp.Zero.SampleApp.EntityFrameworkCore.Tests\bin\Release\net461\Abp.Zero.SampleApp.EntityFrameworkCore.Tests.dll
49-
# - test\Abp.Zero.SampleApp.NHibernateTests\bin\Release\net452\Abp.Zero.SampleApp.NHibernateTests.dll
50-
51-
artifacts:
52-
- path: nupkg\*.nupkg
53-
name: nuget-packages
10+
test: off

build.cake

+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
#tool "nuget:?package=xunit.runner.console&version=2.3.0-beta5-build3769"
2+
3+
#addin "nuget:?package=NuGet.Core"
4+
#addin "nuget:?package=Cake.ExtendedNuGet"
5+
6+
//////////////////////////////////////////////////////////////////////
7+
// ARGUMENTS
8+
//////////////////////////////////////////////////////////////////////
9+
10+
var projectName = "Abp";
11+
var solution = "./" + projectName + ".sln";
12+
13+
var target = Argument("target", "Default");
14+
var configuration = Argument("configuration", "Release");
15+
var toolpath = Argument("toolpath", @"tools");
16+
var branch = Argument("branch", EnvironmentVariable("APPVEYOR_REPO_BRANCH"));
17+
var nugetApiKey = EnvironmentVariable("nugetApiKey");
18+
19+
var testProjects = new List<Tuple<string, string[]>>
20+
{
21+
new Tuple<string, string[]>("Abp.AspNetCore.Tests", new[] { "net461", "netcoreapp2.0" }),
22+
new Tuple<string, string[]>("Abp.AutoMapper.Tests", new[] { "net461", "netcoreapp2.0" }),
23+
new Tuple<string, string[]>("Abp.Castle.Log4Net.Tests", new[] { "net461", "netcoreapp2.0" }),
24+
new Tuple<string, string[]>("Abp.Dapper.NHibernate.Tests", new[] { "net461"}),
25+
new Tuple<string, string[]>("Abp.Dapper.Tests", new[] { "net461" }),
26+
new Tuple<string, string[]>("Abp.EntityFramework.GraphDiff.Tests", new[] { "net461" }),
27+
new Tuple<string, string[]>("Abp.EntityFramework.Tests", new[] { "net461" }),
28+
new Tuple<string, string[]>("Abp.EntityFrameworkCore.Dapper.Tests", new[] { "netcoreapp2.0" }),
29+
new Tuple<string, string[]>("Abp.EntityFrameworkCore.Tests", new[] { "net461", "netcoreapp2.0" }),
30+
new Tuple<string, string[]>("Abp.MailKit.Tests", new[] { "net461", "netcoreapp2.0" }),
31+
new Tuple<string, string[]>("Abp.MemoryDb.Tests", new[] { "net461", "netcoreapp2.0" }),
32+
new Tuple<string, string[]>("Abp.NHibernate.Tests", new[] { "net461" }),
33+
new Tuple<string, string[]>("Abp.Quartz.Tests", new[] { "net461" }),
34+
new Tuple<string, string[]>("Abp.RedisCache.Tests", new[] { "net461", "netcoreapp2.0" }),
35+
new Tuple<string, string[]>("Abp.TestBase.SampleApplication.Tests", new[] { "net461" }),
36+
new Tuple<string, string[]>("Abp.Tests", new[] { "net461", "netcoreapp2.0" }),
37+
new Tuple<string, string[]>("Abp.Web.Api.Tests", new[] { "net461" }),
38+
new Tuple<string, string[]>("Abp.Web.Common.Tests", new[] { "net461", "netcoreapp2.0" }),
39+
new Tuple<string, string[]>("Abp.Web.Mvc.Tests", new[] { "net461" }),
40+
new Tuple<string, string[]>("Abp.Web.Tests", new[] { "net461" }),
41+
new Tuple<string, string[]>("Abp.Zero.SampleApp.NHibernateTests", new[] { "net461" }),
42+
new Tuple<string, string[]>("Abp.Zero.SampleApp.Tests", new[] { "net461" }),
43+
new Tuple<string, string[]>("Abp.ZeroCore.Tests", new[] { "netcoreapp2.0" }),
44+
new Tuple<string, string[]>("Abp.ZeroCore.IdentityServer4.Tests", new[] { "netcoreapp2.0" })
45+
};
46+
47+
48+
var nupkgPath = "nupkg";
49+
var nupkgRegex = $"**/{projectName}*.nupkg";
50+
var nugetPath = toolpath + "/nuget.exe";
51+
var nugetQueryUrl = "https://www.nuget.org/api/v2/";
52+
var nugetPushUrl = "https://www.nuget.org/api/v2/package";
53+
var NUGET_PUSH_SETTINGS = new NuGetPushSettings
54+
{
55+
ToolPath = File(nugetPath),
56+
Source = nugetPushUrl,
57+
ApiKey = nugetApiKey
58+
};
59+
60+
//////////////////////////////////////////////////////////////////////
61+
// TASKS
62+
//////////////////////////////////////////////////////////////////////
63+
64+
Task("Clean")
65+
.Does(() =>
66+
{
67+
Information("Current Branch is:" + EnvironmentVariable("APPVEYOR_REPO_BRANCH"));
68+
CleanDirectories("./src/**/bin");
69+
CleanDirectories("./src/**/obj");
70+
CleanDirectories("./test/**/bin");
71+
CleanDirectories("./test/**/obj");
72+
CleanDirectory(nupkgPath);
73+
});
74+
75+
Task("Restore-NuGet-Packages")
76+
.IsDependentOn("Clean")
77+
.Does(() =>
78+
{
79+
DotNetCoreRestore(solution);
80+
});
81+
82+
Task("Build")
83+
.IsDependentOn("Restore-NuGet-Packages")
84+
.Does(() =>
85+
{
86+
MSBuild(solution, new MSBuildSettings(){Configuration = configuration}
87+
.WithProperty("SourceLinkCreate","true"));
88+
});
89+
90+
Task("Run-Unit-Tests")
91+
.IsDependentOn("Build")
92+
.Does(() =>
93+
{
94+
foreach (Tuple<string, string[]> testProject in testProjects)
95+
{
96+
foreach (string targetFramework in testProject.Item2)
97+
{
98+
Information($"Test execution started for target frameowork: {targetFramework}...");
99+
var testProj = GetFiles($"./test/**/*{testProject.Item1}.csproj").First();
100+
DotNetCoreTest(testProj.FullPath, new DotNetCoreTestSettings { Configuration = "Release", Framework = targetFramework });
101+
}
102+
}
103+
});
104+
105+
Task("Pack")
106+
.IsDependentOn("Run-Unit-Tests")
107+
.Does(() =>
108+
{
109+
var nupkgFiles = GetFiles(nupkgRegex);
110+
MoveFiles(nupkgFiles, nupkgPath);
111+
});
112+
113+
Task("NugetPublish")
114+
.IsDependentOn("Pack")
115+
.WithCriteria(() => branch == "master")
116+
.Does(()=>
117+
{
118+
foreach(var nupkgFile in GetFiles(nupkgRegex))
119+
{
120+
if(!IsNuGetPublished(nupkgFile, nugetQueryUrl))
121+
{
122+
Information("Publishing... " + nupkgFile);
123+
NuGetPush(nupkgFile, NUGET_PUSH_SETTINGS);
124+
}
125+
else
126+
{
127+
Information("Already published, skipping... " + nupkgFile);
128+
}
129+
}
130+
});
131+
132+
//////////////////////////////////////////////////////////////////////
133+
// TASK TARGETS
134+
//////////////////////////////////////////////////////////////////////
135+
136+
Task("Default")
137+
.IsDependentOn("Build")
138+
.IsDependentOn("Run-Unit-Tests")
139+
.IsDependentOn("Pack")
140+
.IsDependentOn("NugetPublish");
141+
142+
//////////////////////////////////////////////////////////////////////
143+
// EXECUTION
144+
//////////////////////////////////////////////////////////////////////
145+
146+
RunTarget(target);

build.ps1

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<#
2+
.SYNOPSIS
3+
This is a Powershell script to bootstrap a Cake build.
4+
.DESCRIPTION
5+
This Powershell script will download NuGet if missing, restore NuGet tools (including Cake)
6+
and execute your Cake build script with the parameters you provide.
7+
.PARAMETER Target
8+
The build script target to run.
9+
.PARAMETER Configuration
10+
The build configuration to use.
11+
.PARAMETER Verbosity
12+
Specifies the amount of information to be displayed.
13+
.PARAMETER WhatIf
14+
Performs a dry run of the build script.
15+
No tasks will be executed.
16+
.PARAMETER ScriptArgs
17+
Remaining arguments are added here.
18+
.LINK
19+
https://cakebuild.net
20+
#>
21+
22+
[CmdletBinding()]
23+
Param(
24+
[string]$Target = "Default",
25+
[ValidateSet("Release", "Debug")]
26+
[string]$Configuration = "Release",
27+
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
28+
[string]$Verbosity = "Verbose",
29+
[switch]$WhatIf,
30+
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
31+
[string[]]$ScriptArgs
32+
)
33+
34+
$CakeVersion = "0.22.2"
35+
$DotNetChannel = "LTS";
36+
$DotNetVersion = "2.0.0";
37+
$DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1";
38+
$NugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
39+
40+
# Temporarily skip verification and opt-in to new in-proc NuGet
41+
$ENV:CAKE_SETTINGS_SKIPVERIFICATION='true'
42+
$ENV:CAKE_NUGET_USEINPROCESSCLIENT='true'
43+
44+
# Make sure tools folder exists
45+
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
46+
$ToolPath = Join-Path $PSScriptRoot "tools"
47+
if (!(Test-Path $ToolPath)) {
48+
Write-Verbose "Creating tools directory..."
49+
New-Item -Path $ToolPath -Type directory | out-null
50+
}
51+
52+
###########################################################################
53+
# INSTALL .NET CORE CLI
54+
###########################################################################
55+
56+
Function Remove-PathVariable([string]$VariableToRemove)
57+
{
58+
$path = [Environment]::GetEnvironmentVariable("PATH", "User")
59+
if ($path -ne $null)
60+
{
61+
$newItems = $path.Split(';', [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove }
62+
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User")
63+
}
64+
65+
$path = [Environment]::GetEnvironmentVariable("PATH", "Process")
66+
if ($path -ne $null)
67+
{
68+
$newItems = $path.Split(';', [StringSplitOptions]::RemoveEmptyEntries) | Where-Object { "$($_)" -inotlike $VariableToRemove }
69+
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process")
70+
}
71+
}
72+
73+
# Get .NET Core CLI path if installed.
74+
$FoundDotNetCliVersion = $null;
75+
if (Get-Command dotnet -ErrorAction SilentlyContinue) {
76+
$FoundDotNetCliVersion = dotnet --version;
77+
}
78+
79+
if($FoundDotNetCliVersion -ne $DotNetVersion) {
80+
$InstallPath = Join-Path $PSScriptRoot ".dotnet"
81+
if (!(Test-Path $InstallPath)) {
82+
mkdir -Force $InstallPath | Out-Null;
83+
}
84+
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1");
85+
& $InstallPath\dotnet-install.ps1 -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath;
86+
87+
Remove-PathVariable "$InstallPath"
88+
$env:PATH = "$InstallPath;$env:PATH"
89+
}
90+
91+
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
92+
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1
93+
94+
###########################################################################
95+
# INSTALL NUGET
96+
###########################################################################
97+
98+
# Make sure nuget.exe exists.
99+
$NugetPath = Join-Path $ToolPath "nuget.exe"
100+
if (!(Test-Path $NugetPath)) {
101+
Write-Host "Downloading NuGet.exe..."
102+
(New-Object System.Net.WebClient).DownloadFile($NugetUrl, $NugetPath);
103+
}
104+
105+
###########################################################################
106+
# INSTALL CAKE
107+
###########################################################################
108+
109+
# Make sure Cake has been installed.
110+
$CakePath = Join-Path $ToolPath "Cake.$CakeVersion/Cake.exe"
111+
if (!(Test-Path $CakePath)) {
112+
Write-Host "Installing Cake..."
113+
Invoke-Expression "&`"$NugetPath`" install Cake -Version $CakeVersion -OutputDirectory `"$ToolPath`"" | Out-Null;
114+
if ($LASTEXITCODE -ne 0) {
115+
Throw "An error occured while restoring Cake from NuGet."
116+
}
117+
}
118+
119+
###########################################################################
120+
# RUN BUILD SCRIPT
121+
###########################################################################
122+
123+
# Build the argument list.
124+
$Arguments = @{
125+
target=$Target;
126+
configuration=$Configuration;
127+
verbosity=$Verbosity;
128+
dryrun=$WhatIf;
129+
}.GetEnumerator() | %{"--{0}=`"{1}`"" -f $_.key, $_.value };
130+
131+
# Start Cake
132+
Write-Host "Running build script..."
133+
Invoke-Expression "& `"$CakePath`" `"build.cake`" $Arguments $ScriptArgs"
134+
exit $LASTEXITCODE

common.props

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<PackageLicenseUrl>https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/LICENSE</PackageLicenseUrl>
88
<RepositoryType>git</RepositoryType>
99
<RepositoryUrl>https://github.com/aspnetboilerplate/aspnetboilerplate</RepositoryUrl>
10+
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
1011
</PropertyGroup>
1112

1213
<ItemGroup>

0 commit comments

Comments
 (0)