Skip to content

Commit 32070f5

Browse files
committed
Updated build scripts to use cake build. #65
1 parent f815f7d commit 32070f5

15 files changed

+301
-4
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -260,4 +260,5 @@ paket-files/
260260
__pycache__/
261261
*.pyc
262262

263-
src/Jaya.app/Contents/MacOS/
263+
src/Jaya.app/Contents/MacOS/
264+
tools

build/build.cake

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// script arguments
2+
var buildNumber = Argument<int>("BuildNumber", 1);
3+
var versionPrefix = Argument("VersionPrefix", "0.0.0");
4+
5+
// public variables
6+
var versionString = "{0}.{0}";
7+
var isGithubActionsBuild = GithubActions.IsRunningOnGithubActions;
8+
9+
Setup(context =>
10+
{
11+
12+
});
13+
14+
Teardown(context =>
15+
{
16+
17+
});
18+
19+
Task("GenerateVersionString")
20+
.Does(() =>
21+
{
22+
versionString = string.Format(versionString, versionPrefix, buildNumber);
23+
Information($"Version {versionString}");
24+
});
25+
26+
Task("Build")
27+
.IsDependentOn("GenerateVersionString")
28+
.Does(() =>
29+
{
30+
Information($"Build {(isGithubActionsBuild ? "is" : "is not")} running on Github Actions infrastructure.");
31+
});
32+
33+
Task("Deploy")
34+
.IsDependentOn("Build")
35+
.Does(() =>
36+
{
37+
38+
});
39+
40+
RunTarget("Deploy");

build/build.ps1

+256
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
##########################################################################
2+
# This is the Cake bootstrapper script for PowerShell.
3+
# This file was downloaded from https://github.com/cake-build/resources
4+
# Feel free to change this file to fit your needs.
5+
##########################################################################
6+
7+
<#
8+
9+
.SYNOPSIS
10+
This is a Powershell script to bootstrap a Cake build.
11+
12+
.DESCRIPTION
13+
This Powershell script will download NuGet if missing, restore NuGet tools (including Cake)
14+
and execute your Cake build script with the parameters you provide.
15+
16+
.PARAMETER Script
17+
The build script to execute.
18+
.PARAMETER Target
19+
The build script target to run.
20+
.PARAMETER Configuration
21+
The build configuration to use.
22+
.PARAMETER Verbosity
23+
Specifies the amount of information to be displayed.
24+
.PARAMETER ShowDescription
25+
Shows description about tasks.
26+
.PARAMETER DryRun
27+
Performs a dry run.
28+
.PARAMETER SkipToolPackageRestore
29+
Skips restoring of packages.
30+
.PARAMETER ScriptArgs
31+
Remaining arguments are added here.
32+
33+
.LINK
34+
https://cakebuild.net
35+
36+
#>
37+
38+
[CmdletBinding()]
39+
Param(
40+
[string]$Script = "build.cake",
41+
[string]$Target,
42+
[string]$Configuration,
43+
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
44+
[string]$Verbosity,
45+
[switch]$ShowDescription,
46+
[Alias("WhatIf", "Noop")]
47+
[switch]$DryRun,
48+
[switch]$SkipToolPackageRestore,
49+
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
50+
[string[]]$ScriptArgs
51+
)
52+
53+
# Attempt to set highest encryption available for SecurityProtocol.
54+
# PowerShell will not set this by default (until maybe .NET 4.6.x). This
55+
# will typically produce a message for PowerShell v2 (just an info
56+
# message though)
57+
try {
58+
# Set TLS 1.2 (3072), then TLS 1.1 (768), then TLS 1.0 (192), finally SSL 3.0 (48)
59+
# Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't
60+
# exist in .NET 4.0, even though they are addressable if .NET 4.5+ is
61+
# installed (.NET 4.5 is an in-place upgrade).
62+
# PowerShell Core already has support for TLS 1.2 so we can skip this if running in that.
63+
if (-not $IsCoreCLR) {
64+
[System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48
65+
}
66+
} catch {
67+
Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to upgrade to .NET Framework 4.5+ and PowerShell v3'
68+
}
69+
70+
[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
71+
function MD5HashFile([string] $filePath)
72+
{
73+
if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf))
74+
{
75+
return $null
76+
}
77+
78+
[System.IO.Stream] $file = $null;
79+
[System.Security.Cryptography.MD5] $md5 = $null;
80+
try
81+
{
82+
$md5 = [System.Security.Cryptography.MD5]::Create()
83+
$file = [System.IO.File]::OpenRead($filePath)
84+
return [System.BitConverter]::ToString($md5.ComputeHash($file))
85+
}
86+
finally
87+
{
88+
if ($file -ne $null)
89+
{
90+
$file.Dispose()
91+
}
92+
}
93+
}
94+
95+
function GetProxyEnabledWebClient
96+
{
97+
$wc = New-Object System.Net.WebClient
98+
$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
99+
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
100+
$wc.Proxy = $proxy
101+
return $wc
102+
}
103+
104+
Write-Host "Preparing to run build script..."
105+
106+
if(!$PSScriptRoot){
107+
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
108+
}
109+
110+
$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
111+
$ADDINS_DIR = Join-Path $TOOLS_DIR "Addins"
112+
$MODULES_DIR = Join-Path $TOOLS_DIR "Modules"
113+
$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
114+
$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe"
115+
$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
116+
$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config"
117+
$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum"
118+
$ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config"
119+
$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config"
120+
121+
# Make sure tools folder exists
122+
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
123+
Write-Verbose -Message "Creating tools directory..."
124+
New-Item -Path $TOOLS_DIR -Type Directory | Out-Null
125+
}
126+
127+
# Make sure that packages.config exist.
128+
if (!(Test-Path $PACKAGES_CONFIG)) {
129+
Write-Verbose -Message "Downloading packages.config..."
130+
try {
131+
$wc = GetProxyEnabledWebClient
132+
$wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG)
133+
} catch {
134+
Throw "Could not download packages.config."
135+
}
136+
}
137+
138+
# Try find NuGet.exe in path if not exists
139+
if (!(Test-Path $NUGET_EXE)) {
140+
Write-Verbose -Message "Trying to find nuget.exe in PATH..."
141+
$existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) }
142+
$NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1
143+
if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) {
144+
Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)."
145+
$NUGET_EXE = $NUGET_EXE_IN_PATH.FullName
146+
}
147+
}
148+
149+
# Try download NuGet.exe if not exists
150+
if (!(Test-Path $NUGET_EXE)) {
151+
Write-Verbose -Message "Downloading NuGet.exe..."
152+
try {
153+
$wc = GetProxyEnabledWebClient
154+
$wc.DownloadFile($NUGET_URL, $NUGET_EXE)
155+
} catch {
156+
Throw "Could not download NuGet.exe."
157+
}
158+
}
159+
160+
# Save nuget.exe path to environment to be available to child processed
161+
$env:NUGET_EXE = $NUGET_EXE
162+
$env:NUGET_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
163+
"mono `"$NUGET_EXE`""
164+
} else {
165+
"`"$NUGET_EXE`""
166+
}
167+
168+
# Restore tools from NuGet?
169+
if(-Not $SkipToolPackageRestore.IsPresent) {
170+
Push-Location
171+
Set-Location $TOOLS_DIR
172+
173+
# Check for changes in packages.config and remove installed tools if true.
174+
[string] $md5Hash = MD5HashFile $PACKAGES_CONFIG
175+
if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
176+
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
177+
Write-Verbose -Message "Missing or changed package.config hash..."
178+
Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery |
179+
Remove-Item -Recurse -Force
180+
}
181+
182+
Write-Verbose -Message "Restoring tools from NuGet..."
183+
184+
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
185+
186+
if ($LASTEXITCODE -ne 0) {
187+
Throw "An error occurred while restoring NuGet tools."
188+
}
189+
else
190+
{
191+
$md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
192+
}
193+
Write-Verbose -Message ($NuGetOutput | Out-String)
194+
195+
Pop-Location
196+
}
197+
198+
# Restore addins from NuGet
199+
if (Test-Path $ADDINS_PACKAGES_CONFIG) {
200+
Push-Location
201+
Set-Location $ADDINS_DIR
202+
203+
Write-Verbose -Message "Restoring addins from NuGet..."
204+
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""
205+
206+
if ($LASTEXITCODE -ne 0) {
207+
Throw "An error occurred while restoring NuGet addins."
208+
}
209+
210+
Write-Verbose -Message ($NuGetOutput | Out-String)
211+
212+
Pop-Location
213+
}
214+
215+
# Restore modules from NuGet
216+
if (Test-Path $MODULES_PACKAGES_CONFIG) {
217+
Push-Location
218+
Set-Location $MODULES_DIR
219+
220+
Write-Verbose -Message "Restoring modules from NuGet..."
221+
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""
222+
223+
if ($LASTEXITCODE -ne 0) {
224+
Throw "An error occurred while restoring NuGet modules."
225+
}
226+
227+
Write-Verbose -Message ($NuGetOutput | Out-String)
228+
229+
Pop-Location
230+
}
231+
232+
# Make sure that Cake has been installed.
233+
if (!(Test-Path $CAKE_EXE)) {
234+
Throw "Could not find Cake.exe at $CAKE_EXE"
235+
}
236+
237+
$CAKE_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
238+
"mono `"$CAKE_EXE`""
239+
} else {
240+
"`"$CAKE_EXE`""
241+
}
242+
243+
# Build an array (not a string) of Cake arguments to be joined later
244+
$cakeArguments = @()
245+
if ($Script) { $cakeArguments += "`"$Script`"" }
246+
if ($Target) { $cakeArguments += "-target=`"$Target`"" }
247+
if ($Configuration) { $cakeArguments += "-configuration=$Configuration" }
248+
if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" }
249+
if ($ShowDescription) { $cakeArguments += "-showdescription" }
250+
if ($DryRun) { $cakeArguments += "-dryrun" }
251+
$cakeArguments += $ScriptArgs
252+
253+
# Start Cake
254+
Write-Host "Running build script..."
255+
Invoke-Expression "& $CAKE_EXE_INVOCATION $($cakeArguments -join " ")"
256+
exit $LASTEXITCODE
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

build/init.bat build/old/init.bat

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

build/sign.ps1 build/old/sign.ps1

File renamed without changes.

src/Jaya.sln

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

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.28307.757
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30128.74
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jaya.Ui", "Jaya.Ui\Jaya.Ui.csproj", "{CDB00482-676D-4BB5-9997-9A1FB368ABA0}"
77
EndProject
@@ -15,7 +15,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jaya.Provider.GoogleDrive",
1515
EndProject
1616
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jaya.Provider.Ftp", "Jaya.Provider.Ftp\Jaya.Provider.Ftp.csproj", "{870AE579-A91F-4F81-AF15-05E45E3B286A}"
1717
EndProject
18-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jaya.Provider.S3", "Jaya.Provider.S3\Jaya.Provider.S3.csproj", "{37A99B8A-3048-410D-8A19-3C7F5BBA8820}"
18+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jaya.Provider.S3", "Jaya.Provider.S3\Jaya.Provider.S3.csproj", "{37A99B8A-3048-410D-8A19-3C7F5BBA8820}"
1919
EndProject
2020
Global
2121
GlobalSection(SolutionConfigurationPlatforms) = preSolution

0 commit comments

Comments
 (0)