Skip to content

Commit

Permalink
(cake-buildGH-2874) Merge Frosting into Cake
Browse files Browse the repository at this point in the history
* fixes cake-build#2874
* Fix Cake styling & breaking changes
* Add bootstrappers to template
* Add Frosting to build
  • Loading branch information
devlead committed Oct 15, 2020
1 parent 844d8b5 commit 3f53cb1
Show file tree
Hide file tree
Showing 124 changed files with 305 additions and 225 deletions.
21 changes: 0 additions & 21 deletions Cake.Frosting.Example/Properties/AssemblyInfo.cs

This file was deleted.

13 changes: 0 additions & 13 deletions Cake.Frosting.Tests/Properties/AssemblyInfo.cs

This file was deleted.

83 changes: 0 additions & 83 deletions Cake.Frosting.sln

This file was deleted.

21 changes: 0 additions & 21 deletions Cake.Frosting/Properties/AssemblyInfo.cs

This file was deleted.

44 changes: 0 additions & 44 deletions Shared.msbuild

This file was deleted.

4 changes: 2 additions & 2 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,11 @@ Task("Create-NuGet-Packages")
.Does<BuildParameters>((context, parameters) =>
{
// Build libraries
var projects = GetFiles("./src/**/*.csproj");
var projects = GetFiles("./src/*/*.csproj");
foreach(var project in projects)
{
var name = project.GetDirectory().FullPath;
if(name.EndsWith("Cake") || name.EndsWith("Tests"))
if(name.EndsWith("Cake") || name.EndsWith("Tests") || name.EndsWith("Example"))
{
continue;
}
Expand Down
5 changes: 5 additions & 0 deletions build/parameters.cake
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ public class BuildParameters
.WithProperty("AssemblyVersion", Version.Version)
.WithProperty("FileVersion", Version.Version)
.WithProperty("PackageReleaseNotes", string.Concat("\"", releaseNotes, "\""));

if (!IsLocalBuild)
{
MSBuildSettings.WithProperty("TemplateVersion", Version.SemVersion);
}
}

private static bool IsBuildTagged(BuildSystem buildSystem)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
<TargetFrameworks>net461;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0;net5.0</TargetFrameworks>
<AssemblyName>Cake.Frosting.Example</AssemblyName>
<OutputType>Exe</OutputType>
<LangVersion>7</LangVersion>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions src/Cake.Frosting.Template/Cake.Frosting.Template.csproj
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>
70 changes: 70 additions & 0 deletions src/Cake.Frosting.Template/build.ps1
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;
38 changes: 38 additions & 0 deletions src/Cake.Frosting.Template/build.sh
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 -- "$@"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"author": "Patrik Svensson ([email protected])",
"classifications": [ "Cake", "Frosting" ],
"name": "Cake Frosting Build Script",
"identity": "Cake.Frosting",
"shortName": "cakefrosting",
"sourceName": "temp",
"tags": {
"language": "C#"
}
}
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>
Loading

0 comments on commit 3f53cb1

Please sign in to comment.