forked from cake-build/cake
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cake-build#2875 from devlead/feature/cake-buildgh-…
…2874 GH2874: Merge Frosting into Cake
- Loading branch information
Showing
125 changed files
with
5,612 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>net461;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0;net5.0</TargetFrameworks> | ||
<AssemblyName>Cake.Frosting.Example</AssemblyName> | ||
<OutputType>Exe</OutputType> | ||
<LangVersion>7</LangVersion> | ||
<EmbedUntrackedSources>true</EmbedUntrackedSources> | ||
</PropertyGroup> | ||
|
||
<Import Project="$(MSBuildThisFileDirectory)..\Shared.msbuild" /> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Cake.Frosting\Cake.Frosting.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace Cake.Frosting.Example | ||
{ | ||
public class Program | ||
{ | ||
public static int Main(string[] args) | ||
{ | ||
// Create the host. | ||
var host = new CakeHostBuilder() | ||
.UseStartup<Startup>() | ||
.WithArguments(args) | ||
.Build(); | ||
|
||
// Run the host. | ||
return host.Run(); | ||
} | ||
} | ||
|
||
public class Startup : IFrostingStartup | ||
{ | ||
public void Configure(ICakeServices services) | ||
{ | ||
services.UseContext<Settings>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Cake.Core; | ||
|
||
namespace Cake.Frosting.Example | ||
{ | ||
public class Settings : FrostingContext | ||
{ | ||
public bool Magic { get; set; } | ||
|
||
public Settings(ICakeContext context) | ||
: base(context) | ||
{ | ||
// You could also use a CakeLifeTime<Settings> | ||
// to provide a Setup method to setup the context. | ||
Magic = context.Arguments.HasArgument("magic"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Threading.Tasks; | ||
using Cake.Core; | ||
using Cake.Core.Diagnostics; | ||
|
||
namespace Cake.Frosting.Example | ||
{ | ||
public sealed class Hello : FrostingTask<Settings> | ||
{ | ||
} | ||
|
||
[Dependency(typeof(Hello))] | ||
public sealed class World : AsyncFrostingTask<Settings> | ||
{ | ||
// Tasks can be asynchronous | ||
public override async Task RunAsync(Settings context) | ||
{ | ||
context.Log.Information("About to do something expensive"); | ||
await Task.Delay(1500); | ||
context.Log.Information("Done"); | ||
} | ||
} | ||
|
||
[Dependency(typeof(World))] | ||
public sealed class Magic : FrostingTask<Settings> | ||
{ | ||
public override bool ShouldRun(Settings context) | ||
{ | ||
// Don't run this task on OSX. | ||
return context.Environment.Platform.Family != PlatformFamily.OSX; | ||
} | ||
|
||
public override void Run(Settings context) | ||
{ | ||
context.Log.Information("Value is: {0}", context.Magic); | ||
} | ||
} | ||
|
||
[TaskName("Default")] | ||
[Dependency(typeof(Magic))] | ||
public class DefaultTask : FrostingTask | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<PackageType>Template</PackageType> | ||
<AssemblyName>Cake.Frosting.Template</AssemblyName> | ||
<Title>Cake.Frosting templates for the .NET SDK.</Title> | ||
<Description>Cake.Frosting templates for the .NET SDK.</Description> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
|
||
<IncludeContentInPack>true</IncludeContentInPack> | ||
<IncludeBuildOutput>false</IncludeBuildOutput> | ||
<ContentTargetFolders>content</ContentTargetFolders> | ||
<NoWarn>NU5110;NU5111;NU5128</NoWarn> | ||
</PropertyGroup> | ||
|
||
<Import Project="$(MSBuildThisFileDirectory)..\Shared.msbuild" /> | ||
|
||
<ItemGroup> | ||
<Content Include="templates\**\*" Exclude="templates\**\bin\**;templates\**\obj\**" /> | ||
<Content Include="../../build.config" Link="templates/cakefrosting/build.config" PackagePath="/content/templates/cakefrosting/build.config" /> | ||
<Content Include="build.ps1" Link="templates/cakefrosting/build.ps1" PackagePath="/content/templates/cakefrosting/build.ps1" /> | ||
<Content Include="build.sh" Link="templates/cakefrosting/build.sh" PackagePath="/content/templates/cakefrosting/build.sh" /> | ||
<Compile Remove="**\*" /> | ||
</ItemGroup> | ||
|
||
<Target Name="VersionBuild" BeforeTargets="PrepareForBuild" Condition="'$(TemplateVersion)'!=''"> | ||
<XmlPoke XmlInputPath="templates\cakefrosting\build\Build.csproj" Query="Project/ItemGroup/PackageReference/@Version" Value="$(TemplateVersion)" /> | ||
</Target> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env pwsh | ||
$DotNetInstallerUri = 'https://dot.net/v1/dotnet-install.ps1'; | ||
$DotNetUnixInstallerUri = 'https://dot.net/v1/dotnet-install.sh' | ||
$DotNetChannel = 'LTS' | ||
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent | ||
|
||
[string] $DotNetVersion= '' | ||
foreach($line in Get-Content (Join-Path $PSScriptRoot 'build.config')) | ||
{ | ||
if ($line -like 'DOTNET_VERSION=*') { | ||
$DotNetVersion =$line.SubString(15) | ||
} | ||
} | ||
|
||
|
||
if ([string]::IsNullOrEmpty($DotNetVersion)) { | ||
'Failed to parse .NET Core SDK Version' | ||
exit 1 | ||
} | ||
|
||
$DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1"; | ||
|
||
# Make sure tools folder exists | ||
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent | ||
$ToolPath = Join-Path $PSScriptRoot "tools" | ||
if (!(Test-Path $ToolPath)) { | ||
Write-Verbose "Creating tools directory..." | ||
New-Item -Path $ToolPath -Type directory | out-null | ||
} | ||
|
||
########################################################################### | ||
# INSTALL .NET CORE CLI | ||
########################################################################### | ||
|
||
Function Remove-PathVariable([string]$VariableToRemove) | ||
{ | ||
$path = [Environment]::GetEnvironmentVariable("PATH", "User") | ||
$newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove } | ||
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User") | ||
$path = [Environment]::GetEnvironmentVariable("PATH", "Process") | ||
$newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove } | ||
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process") | ||
} | ||
|
||
# Get .NET Core CLI path if installed. | ||
$FoundDotNetCliVersion = $null; | ||
if (Get-Command dotnet -ErrorAction SilentlyContinue) { | ||
$FoundDotNetCliVersion = dotnet --version; | ||
} | ||
|
||
if($FoundDotNetCliVersion -ne $DotNetVersion) { | ||
$InstallPath = Join-Path $PSScriptRoot ".dotnet" | ||
if (!(Test-Path $InstallPath)) { | ||
mkdir -Force $InstallPath | Out-Null; | ||
} | ||
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1"); | ||
& $InstallPath\dotnet-install.ps1 -Version $DotNetVersion -InstallDir $InstallPath; | ||
|
||
Remove-PathVariable "$InstallPath" | ||
$env:PATH = "$InstallPath;$env:PATH" | ||
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 | ||
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1 | ||
} | ||
|
||
########################################################################### | ||
# RUN BUILD SCRIPT | ||
########################################################################### | ||
|
||
dotnet run --project build/Build.csproj -- $args | ||
exit $LASTEXITCODE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
# Define varibles | ||
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
source $SCRIPT_DIR/build.config | ||
|
||
if [ "$DOTNET_VERSION" = "" ]; then | ||
echo "An error occured while parsing .NET Core SDK version." | ||
exit 1 | ||
fi | ||
|
||
########################################################################### | ||
# INSTALL .NET CORE CLI | ||
########################################################################### | ||
|
||
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 | ||
export DOTNET_CLI_TELEMETRY_OPTOUT=1 | ||
export DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0 | ||
export DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX=2 | ||
|
||
DOTNET_INSTALLED_VERSION=$(dotnet --version 2>&1) | ||
|
||
if [ "$DOTNET_VERSION" != "$DOTNET_INSTALLED_VERSION" ]; then | ||
echo "Installing .NET CLI..." | ||
if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then | ||
mkdir "$SCRIPT_DIR/.dotnet" | ||
fi | ||
curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" https://dot.net/v1/dotnet-install.sh | ||
bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version $DOTNET_VERSION --install-dir .dotnet --no-path | ||
export PATH="$SCRIPT_DIR/.dotnet":$PATH | ||
export DOTNET_ROOT="$SCRIPT_DIR/.dotnet" | ||
fi | ||
|
||
########################################################################### | ||
# RUN BUILD SCRIPT | ||
########################################################################### | ||
|
||
echo "Running build script.." | ||
dotnet run --project ./build/Build.csproj -- "$@" |
11 changes: 11 additions & 0 deletions
11
src/Cake.Frosting.Template/templates/cakefrosting/.template.config/template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"author": "Patrik Svensson, Mattias Karlsson, Gary Ewan Park, Alistair Chapman, Martin Björkström, Dave Glick, Pascal Berger, Jérémie Desautels, Enrico Campidoglio and contributors", | ||
"classifications": [ "Cake", "Frosting" ], | ||
"name": "Cake Frosting Build Script", | ||
"identity": "Cake.Frosting", | ||
"shortName": "cakefrosting", | ||
"sourceName": "temp", | ||
"tags": { | ||
"language": "C#" | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Cake.Frosting.Template/templates/cakefrosting/build/Build.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<PackAsTool>true</PackAsTool> | ||
<!-- Make sure start same folder .NET Core CLI and Visual Studio --> | ||
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Cake.Frosting" Version="1.0.0" /> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.