Skip to content

Commit

Permalink
updated to cake 0.018 and added test and cake build
Browse files Browse the repository at this point in the history
  • Loading branch information
phmarques committed Mar 10, 2017
1 parent 2a8ed83 commit 5a69c74
Show file tree
Hide file tree
Showing 11 changed files with 343 additions and 65 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,6 @@ paket-files/
# JetBrains Rider
.idea/
*.sln.iml

tools/
!tools/package.config
4 changes: 2 additions & 2 deletions Cake.DoInDirectory/Cake.DoInDirectory.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
<DocumentationFile>bin\Release\Cake.DoInDirectory.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Cake.Core, Version=0.13.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Cake.Core.0.13.0\lib\net45\Cake.Core.dll</HintPath>
<Reference Include="Cake.Core, Version=0.18.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Cake.Core.0.18.0\lib\net45\Cake.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down
2 changes: 1 addition & 1 deletion Cake.DoInDirectory/Cake.DoInDirectory.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.DoInDirectory", "Cake.DoInDirectory.csproj", "{E193A369-4372-46BD-A51B-D6C61E0FA671}"
EndProject
Expand Down
10 changes: 6 additions & 4 deletions Cake.DoInDirectory/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

Expand Down Expand Up @@ -31,6 +31,8 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
// [assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]

[assembly: AssemblyInformationalVersion("0.1.0+18.Branch.master.Sha.2a8ed838b8574b4ce69b30aed529d440485d0f20")]
2 changes: 1 addition & 1 deletion Cake.DoInDirectory/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Cake.Core" version="0.13.0" targetFramework="net46" />
<package id="Cake.Core" version="0.18.0" targetFramework="net46" />
</packages>
38 changes: 9 additions & 29 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,13 @@
# Release Versions
version: 0.1.1
# Pre-Release Versions
# version: 0.0.2-build{build}
environment:
nuget_api_token:
secure: 0z9yOFGpfQzF7ZsJqzyLj8ckqPIv5FZ7+2TjiCUVR31ewZ7Ah2reiZ9WMubFXwAb

build_script:
- ps: .\build.ps1

test: off

branches:
only:
- master

assembly_info:
patch: true
file: AssemblyInfo.*
assembly_version: "{version}"
assembly_file_version: "{version}"
assembly_informational_version: "{version}"

configuration: Release

before_build:
- nuget restore .\Cake.DoInDirectory\Cake.DoInDirectory.sln

build:
project: .\Cake.DoInDirectory\Cake.DoInDirectory.sln

after_test:
- ps: .\nuget\pack.ps1

artifacts:
- path: Cake.DoInDirectory\bin\Release\Cake.DoInDirectory.dll
name: Cake.DoInDirectory.dll
- path: Cake.DoInDirectory\bin\Release\Cake.DoInDirectory.XML
name: Cake.DoInDirectory.XML
- path: '**\Cake.DoInDirectory*.nupkg'
- /feature/.*/
89 changes: 89 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#tool "nuget:?package=GitVersion.CommandLine&version=3.6.2"

var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var nugetApiToken = EnvironmentVariable("nuget_api_token");
var solution = File("Cake.DoInDirectory/Cake.DoInDirectory.sln");

var version = GitVersion(new GitVersionSettings { UpdateAssemblyInfo = true });
if (AppVeyor.IsRunningOnAppVeyor) {
AppVeyor.UpdateBuildVersion(version.NuGetVersionV2);
}

Task("Clean")
.Does(() =>
{
CreateDirectory("./nuget");
CleanDirectory("./nuget");
CleanDirectories("./**/bin");
CleanDirectories("./**/obj");
});

Task("Build")
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore(solution);
MSBuild(solution, configurator =>
configurator
.SetConfiguration(configuration)
.SetVerbosity(Verbosity.Minimal));
});

Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
CakeExecuteScript("./test.cake");
});

Task("Pack")
.IsDependentOn("Test")
.Does(() =>
{
var nuGetPackSettings = new NuGetPackSettings
{
Id = "Cake.DoInDirectory",
Version = version.NuGetVersionV2,
Authors = new[] {"pitermarx"},
Description = "An extension to Cake Build. Changes the current directory.",
ProjectUrl = new Uri("https://github.com/pitermarx/Cake.DoInDirectory"),
Tags = new [] {"cake","io", "directory"},
Files = new [] {
new NuSpecContent { Source = "Cake.DoInDirectory/bin/Release/Cake.DoInDirectory.dll", Target = "lib/net45" },
new NuSpecContent { Source = "Cake.DoInDirectory/bin/Release/Cake.DoInDirectory.XML", Target = "lib/net45" },
new NuSpecContent { Source = "Cake.DoInDirectory/bin/Release/Cake.DoInDirectory.pdb", Target = "lib/net45" }
},
BasePath = "./",
OutputDirectory = "./nuget"
};

NuGetPack(nuGetPackSettings);
});

Task("Publish")
.WithCriteria(AppVeyor.IsRunningOnAppVeyor)
.IsDependentOn("Pack")
.Does(() =>
{
var file = GetFiles("nuget/*.nupkg").First();
AppVeyor.UploadArtifact(file);

var tagged = AppVeyor.Environment.Repository.Tag.IsTag &&
!string.IsNullOrWhiteSpace(AppVeyor.Environment.Repository.Tag.Name);

if (tagged)
{
// Push the package.
NuGetPush(file, new NuGetPushSettings
{
Source = "https://www.nuget.org/api/v2/package",
ApiKey = nugetApiToken
});
}
});

Task("Default")
.IsDependentOn("Publish");

RunTarget(target);
189 changes: 189 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
##########################################################################
# This is the Cake bootstrapper script for PowerShell.
# This file was downloaded from https://github.com/cake-build/resources
# Feel free to change this file to fit your needs.
##########################################################################

<#
.SYNOPSIS
This is a Powershell script to bootstrap a Cake build.
.DESCRIPTION
This Powershell script will download NuGet if missing, restore NuGet tools (including Cake)
and execute your Cake build script with the parameters you provide.
.PARAMETER Script
The build script to execute.
.PARAMETER Target
The build script target to run.
.PARAMETER Configuration
The build configuration to use.
.PARAMETER Verbosity
Specifies the amount of information to be displayed.
.PARAMETER Experimental
Tells Cake to use the latest Roslyn release.
.PARAMETER WhatIf
Performs a dry run of the build script.
No tasks will be executed.
.PARAMETER Mono
Tells Cake to use the Mono scripting engine.
.PARAMETER SkipToolPackageRestore
Skips restoring of packages.
.PARAMETER ScriptArgs
Remaining arguments are added here.
.LINK
http://cakebuild.net
#>

[CmdletBinding()]
Param(
[string]$Script = "build.cake",
[string]$Target = "Default",
[ValidateSet("Release", "Debug")]
[string]$Configuration = "Release",
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
[string]$Verbosity = "Verbose",
[switch]$Experimental,
[Alias("DryRun","Noop")]
[switch]$WhatIf,
[switch]$Mono,
[switch]$SkipToolPackageRestore,
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$ScriptArgs
)

[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
function MD5HashFile([string] $filePath)
{
if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf))
{
return $null
}

[System.IO.Stream] $file = $null;
[System.Security.Cryptography.MD5] $md5 = $null;
try
{
$md5 = [System.Security.Cryptography.MD5]::Create()
$file = [System.IO.File]::OpenRead($filePath)
return [System.BitConverter]::ToString($md5.ComputeHash($file))
}
finally
{
if ($file -ne $null)
{
$file.Dispose()
}
}
}

Write-Host "Preparing to run build script..."

if(!$PSScriptRoot){
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
}

$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe"
$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config"
$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum"

# Should we use mono?
$UseMono = "";
if($Mono.IsPresent) {
Write-Verbose -Message "Using the Mono based scripting engine."
$UseMono = "-mono"
}

# Should we use the new Roslyn?
$UseExperimental = "";
if($Experimental.IsPresent -and !($Mono.IsPresent)) {
Write-Verbose -Message "Using experimental version of Roslyn."
$UseExperimental = "-experimental"
}

# Is this a dry run?
$UseDryRun = "";
if($WhatIf.IsPresent) {
$UseDryRun = "-dryrun"
}

# Make sure tools folder exists
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
Write-Verbose -Message "Creating tools directory..."
New-Item -Path $TOOLS_DIR -Type directory | out-null
}

# Make sure that packages.config exist.
if (!(Test-Path $PACKAGES_CONFIG)) {
Write-Verbose -Message "Downloading packages.config..."
try { (New-Object System.Net.WebClient).DownloadFile("http://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch {
Throw "Could not download packages.config."
}
}

# Try find NuGet.exe in path if not exists
if (!(Test-Path $NUGET_EXE)) {
Write-Verbose -Message "Trying to find nuget.exe in PATH..."
$existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) }
$NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1
if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) {
Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)."
$NUGET_EXE = $NUGET_EXE_IN_PATH.FullName
}
}

# Try download NuGet.exe if not exists
if (!(Test-Path $NUGET_EXE)) {
Write-Verbose -Message "Downloading NuGet.exe..."
try {
(New-Object System.Net.WebClient).DownloadFile($NUGET_URL, $NUGET_EXE)
} catch {
Throw "Could not download NuGet.exe."
}
}

# Save nuget.exe path to environment to be available to child processed
$ENV:NUGET_EXE = $NUGET_EXE

# Restore tools from NuGet?
if(-Not $SkipToolPackageRestore.IsPresent) {
Push-Location
Set-Location $TOOLS_DIR

# Check for changes in packages.config and remove installed tools if true.
[string] $md5Hash = MD5HashFile($PACKAGES_CONFIG)
if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
Write-Verbose -Message "Missing or changed package.config hash..."
Remove-Item * -Recurse -Exclude packages.config,nuget.exe
}

Write-Verbose -Message "Restoring tools from NuGet..."
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""

if ($LASTEXITCODE -ne 0) {
Throw "An error occured while restoring NuGet tools."
}
else
{
$md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
}
Write-Verbose -Message ($NuGetOutput | out-string)
Pop-Location
}

# Make sure that Cake has been installed.
if (!(Test-Path $CAKE_EXE)) {
Throw "Could not find Cake.exe at $CAKE_EXE"
}

# Start Cake
Write-Host "Running build script..."
Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs"
exit $LASTEXITCODE
18 changes: 0 additions & 18 deletions nuget/Cake.DoInDirectory.nuspec

This file was deleted.

Loading

0 comments on commit 5a69c74

Please sign in to comment.