Skip to content

Commit f61731a

Browse files
committed
Added cake.ps1
1 parent 42481c9 commit f61731a

File tree

4 files changed

+144
-1
lines changed

4 files changed

+144
-1
lines changed

ReleaseNotes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### New in 0.0.5 (Released 2017/06/30)
2+
* Added cake.ps1
3+
14
### New in 0.0.4 (Released 2017/06/30)
25
* Added GetScriptHost to get new instance of IScriptHost
36

src/Cake.Bridge.sln

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ VisualStudioVersion = 15.0.26228.9
44
MinimumVisualStudioVersion = 15.0.26124.0
55
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cake.Bridge", "Cake.Bridge\Cake.Bridge.csproj", "{C99AE694-B461-49EC-9633-D72ADC4AAFE8}"
66
EndProject
7-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CakeConsoleRunner", "CakeConsoleRunner\CakeConsoleRunner.csproj", "{B806E492-A0E3-490C-96FA-E9DBFCD10CB1}"
7+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CakeConsoleRunner", "CakeConsoleRunner\CakeConsoleRunner.csproj", "{B806E492-A0E3-490C-96FA-E9DBFCD10CB1}"
88
EndProject
99
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{67F8B8E2-34F7-4CCB-850C-8DC5651B1FB1}"
1010
ProjectSection(SolutionItems) = preProject
1111
..\build.csx = ..\build.csx
12+
cake.fsx = cake.fsx
13+
cake.ps1 = cake.ps1
1214
EndProjectSection
1315
EndProject
1416
Global

src/Cake.Bridge/Cake.Bridge.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
<Pack>true</Pack>
2828
<PackagePath>content\</PackagePath>
2929
</Content>
30+
<Content Include="..\cake.ps1">
31+
<Pack>true</Pack>
32+
<PackagePath>content\</PackagePath>
33+
</Content>
3034
</ItemGroup>
3135

3236
</Project>

src/cake.ps1

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
######################################################################
2+
## NAMESPACE IMPORTS
3+
######################################################################
4+
using namespace Cake.Bridge
5+
using namespace Cake.Common
6+
using namespace Cake.Common.Diagnostics
7+
using namespace Cake.Common.IO
8+
using namespace Cake.Common.Tools.DotNetCore
9+
using namespace Cake.Common.Tools.DotNetCore.Build
10+
using namespace Cake.Common.Tools.DotNetCore.Pack
11+
using namespace Cake.Core
12+
using namespace Cake.Core.IO
13+
using namespace Cake.Core.Scripting
14+
using namespace System
15+
using namespace System.Linq
16+
$ErrorActionPreference = "Stop"
17+
18+
######################################################################
19+
## FETCH DEPENDENCIES
20+
######################################################################
21+
[string] $CakeVersion = "0.20.0"
22+
[string] $BridgeVersion = "0.0.5-alpha"
23+
24+
[string] $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
25+
[string] $ToolsPath = Join-Path $PSScriptRoot "tools"
26+
[string] $CakeCorePath = Join-Path $ToolsPath "Cake.Core.$CakeVersion/lib/net45/Cake.Core.dll"
27+
[string] $CakeCommonPath = Join-Path $ToolsPath "Cake.Common.$CakeVersion/lib/net45/Cake.Common.dll"
28+
[string] $CakeBridgePath = Join-Path $ToolsPath "Cake.Bridge.$BridgeVersion/lib/net45/Cake.Bridge.dll"
29+
30+
Add-Type -AssemblyName System.IO.Compression.FileSystem
31+
Function Unzip
32+
{
33+
param([string]$zipfile, [string]$outpath)
34+
35+
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
36+
}
37+
38+
Function NugetInstall
39+
{
40+
param(
41+
[string]$PackageId,
42+
[string]$PackageVersion,
43+
[string]$ToolsPath
44+
)
45+
(New-Object System.Net.WebClient).DownloadFile("https://www.nuget.org/api/v2/package/$PackageId/$PackageVersion", "$ToolsPath\$PackageId.zip")
46+
Unzip "$ToolsPath\$PackageId.zip" "$ToolsPath/$PackageId.$PackageVersion"
47+
Remove-Item "$ToolsPath\$PackageId.zip"
48+
}
49+
if (!(Test-Path $ToolsPath))
50+
{
51+
New-Item -Path $ToolsPath -Type directory | Out-Null
52+
}
53+
54+
if (!(Test-Path $CakeCorePath))
55+
{
56+
NugetInstall 'Cake.Core' $CakeVersion $ToolsPath
57+
}
58+
59+
if (!(Test-Path $CakeCommonPath))
60+
{
61+
NugetInstall 'Cake.Common' $CakeVersion $ToolsPath
62+
}
63+
64+
if (!(Test-Path $CakeBridgePath))
65+
{
66+
NugetInstall 'Cake.Bridge' $BridgeVersion $ToolsPath
67+
}
68+
69+
######################################################################
70+
## Reference DEPENDENCIES
71+
######################################################################
72+
Add-Type -Path $CakeCorePath
73+
Add-Type -Path $CakeCommonPath
74+
Add-Type -Path $CakeBridgePath
75+
76+
######################################################################
77+
## GLOBALS / HELPERS
78+
######################################################################
79+
[IScriptHost] $bridge = [CakeBridge]::GetScriptHost()
80+
[ICakeContext] $context = $bridge.Context
81+
82+
Function Task {
83+
[OutputType('Cake.Core.CakeTaskBuilder')]
84+
[cmdletbinding()]
85+
Param (
86+
[parameter(ValueFromPipeline)]
87+
[String]$TaskName
88+
)
89+
90+
return $bridge.Task($TaskName)
91+
}
92+
Function Does {
93+
[OutputType('Cake.Core.CakeTaskBuilder')]
94+
[cmdletbinding()]
95+
Param (
96+
[parameter(ValueFromPipeline)]
97+
$Task,
98+
[System.Action] $Action
99+
)
100+
101+
return [CakeTaskBuilderExtensions]::Does($Task, $Action)
102+
}
103+
104+
Function IsDependentOn {
105+
[OutputType('Cake.Core.CakeTaskBuilder')]
106+
[cmdletbinding()]
107+
Param (
108+
[parameter(ValueFromPipeline)]
109+
$Task,
110+
$Dependency
111+
)
112+
113+
return [CakeTaskBuilderExtensions]::IsDependentOn($Task, $Dependency)
114+
}
115+
116+
Function RunTarget {
117+
[cmdletbinding()]
118+
Param (
119+
[parameter(ValueFromPipeline)]
120+
$Task
121+
)
122+
123+
$bridge.RunTarget($Task.Task.Name) | Out-Null
124+
}
125+
126+
Function Setup {
127+
param([Action[ICakeContext]] $action)
128+
$bridge.Setup($action)
129+
}
130+
131+
Function Teardown {
132+
param([Action[ITeardownContext]] $action)
133+
$bridge.Teardown($action)
134+
}

0 commit comments

Comments
 (0)