Skip to content

Commit

Permalink
build with cake
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Feb 11, 2018
1 parent f25055c commit 53c3f41
Show file tree
Hide file tree
Showing 9 changed files with 457 additions and 69 deletions.
66 changes: 4 additions & 62 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# configuration for develop/CI branch
# configuration for develop and master branch

-
branches:
only:
- develop
- master

skip_tags: true
image: Visual Studio 2017
Expand All @@ -13,73 +14,14 @@
pull_requests:
do_not_increment_build_number: false

install:
- choco install gitversion.portable -pre -y

before_build:
- ps: cd src
- ps: .paket\paket restore
- ps: cd..
- ps: gitversion /l console /output buildserver /updateAssemblyInfo

build:
verbosity: minimal

after_build:
- ps: cd src
- ps: .paket\paket pack --version $env:GitVersion_NuGetVersion bin
- ps: cd..

cache:
- src\packages -> **\packages.config
# - '%USERPROFILE%\.nuget\packages -> **\project.json'

artifacts:
- path: \src\bin\MahApps.Metro.*.nupkg
- path: \src\bin\MetroDemo\
name: MetroDemo.v$(GitVersion_NuGetVersion)
type: zip
- path: \src\bin\Caliburn.Metro.Demo\
name: Caliburn.MetroDemo.v$(GitVersion_NuGetVersion)
type: zip

# configuration for master/Release branch
-
branches:
only:
- master

skip_tags: true
image: Visual Studio 2017
configuration: Release
platform: Any CPU

install:
- choco install gitversion.portable -pre -y

before_build:
- ps: cd src
- ps: .paket\paket restore
- ps: cd..
- ps: gitversion /l console /output buildserver /updateAssemblyInfo

build:
verbosity: minimal

after_build:
- ps: cd src
- ps: .paket\paket pack --version $env:GitVersion_NuGetVersion bin
- ps: .\build.ps1 -Target appveyor
- ps: cd..

cache:
- src\packages -> **\packages.config
# - '%USERPROFILE%\.nuget\packages -> **\project.json'

artifacts:
- path: \src\bin\MahApps.Metro.*.nupkg
- path: \src\bin\MetroDemo\
name: MetroDemo.v$(GitVersion_NuGetVersion)
type: zip
- path: \src\bin\Caliburn.Metro.Demo\
name: Caliburn.MetroDemo.v$(GitVersion_NuGetVersion)
type: zip
- path: \src\Publish\*.*
Binary file modified src/.paket/paket.bootstrapper.exe
Binary file not shown.
Binary file modified src/.paket/paket.exe
Binary file not shown.
18 changes: 16 additions & 2 deletions src/.paket/paket.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<RestorePackages Condition=" '$(RestorePackages)' == '' ">true</RestorePackages>
<PaketToolsPath>$(MSBuildThisFileDirectory)</PaketToolsPath>
<PaketRootPath>$(MSBuildThisFileDirectory)..\</PaketRootPath>
<PaketLockFilePath>$(PaketRootPath)paket.lock</PaketLockFilePath>
<PaketRestoreCacheFile>$(PaketRootPath)paket-files\paket.restore.cached</PaketRestoreCacheFile>
<MonoPath Condition="'$(MonoPath)' == '' And Exists('/Library/Frameworks/Mono.framework/Commands/mono')">/Library/Frameworks/Mono.framework/Commands/mono</MonoPath>
<MonoPath Condition="'$(MonoPath)' == ''">mono</MonoPath>
</PropertyGroup>
Expand Down Expand Up @@ -43,16 +45,28 @@

<PropertyGroup>
<!-- Commands -->
<RestoreCommand>$(PaketCommand) restore --references-files "$(PaketReferences)"</RestoreCommand>
<RestoreCommand>$(PaketCommand) restore --references-file "$(PaketReferences)"</RestoreCommand>
<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">RestorePackages; $(BuildDependsOn);</BuildDependsOn>
</PropertyGroup>
<Target Name="RestorePackages">
<PropertyGroup>
<PaketRestoreRequired>true</PaketRestoreRequired>
</PropertyGroup>

<PropertyGroup Condition="Exists('$(PaketRestoreCacheFile)') ">
<PaketRestoreCachedHash>$([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)'))</PaketRestoreCachedHash>
<PaketRestoreLockFileHash>$([System.IO.File]::ReadAllText('$(PaketLockFilePath)'))</PaketRestoreLockFileHash>
<PaketRestoreRequired>true</PaketRestoreRequired>
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '$(PaketRestoreCachedHash)' ">false</PaketRestoreRequired>
<PaketRestoreRequired Condition=" '$(PaketRestoreLockFileHash)' == '' ">true</PaketRestoreRequired>
</PropertyGroup>

<Exec Command="$(RestoreCommand)"
IgnoreStandardErrorWarningFormat="true"
WorkingDirectory="$(PaketRootPath)"
ContinueOnError="false"
Condition=" Exists('$(PaketReferences)') AND '$(PaketReferences)' != '' "
Condition=" '$(PaketRestoreRequired)' == 'true' AND Exists('$(PaketReferences)') AND '$(PaketReferences)' != '' "
/>
</Target>
</Project>
123 changes: 123 additions & 0 deletions src/build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@

//////////////////////////////////////////////////////////////////////
// TOOLS / ADDINS
//////////////////////////////////////////////////////////////////////

#tool paket:?package=GitVersion.CommandLine
#tool paket:?package=gitreleasemanager
#tool paket:?package=xunit.runner.console
#addin paket:?package=Cake.Figlet
#addin paket:?package=Cake.Paket

//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////

var target = Argument("target", "Default");
if (string.IsNullOrWhiteSpace(target))
{
target = "Default";
}

var configuration = Argument("configuration", "Release");
if (string.IsNullOrWhiteSpace(configuration))
{
configuration = "Release";
}

//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////

// Set build version
GitVersion(new GitVersionSettings { OutputType = GitVersionOutput.BuildServer });

// Define directories.
var buildDir = Directory("./bin");

//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////

Setup(context =>
{
Information(Figlet("MahApps.Metro"));
});

Task("Clean")
.Does(() =>
{
CleanDirectory(buildDir);
});

Task("Paket-Restore")
.IsDependentOn("Clean")
.Does(() =>
{
PaketRestore();
});

Task("Update-SolutionInfo")
.Does(() =>
{
var solutionInfo = "./MahApps.Metro/MahApps.Metro/Properties/AssemblyInfo.cs";
GitVersion(new GitVersionSettings { UpdateAssemblyInfo = true, UpdateAssemblyInfoFilePath = solutionInfo});
});

Task("Build")
.IsDependentOn("Paket-Restore")
.Does(() =>
{
if(IsRunningOnWindows())
{
// Use MSBuild
MSBuild("./MahApps.Metro.sln", settings => settings.SetMaxCpuCount(0).SetConfiguration(configuration));
}
});

Task("Paket-Pack")
//.WithCriteria(ShouldRunRelease())
.Does(() =>
{
var version = GitVersion();
EnsureDirectoryExists("./Publish");
PaketPack("./Publish", new PaketPackSettings { Version = version.NuGetVersion });
});

Task("Zip-Demos")
//.WithCriteria(ShouldRunRelease())
.Does(() =>
{
var version = GitVersion();
EnsureDirectoryExists("./Publish");
Zip("./bin/MetroDemo/", "./Publish/MetroDemo-v" + version.NuGetVersion + ".zip");
Zip("./bin/Caliburn.Metro.Demo/", "./Publish/Caliburn.MetroDemo-v" + version.NuGetVersion + ".zip");
});

Task("Unit-Tests")
//.WithCriteria(ShouldRunRelease())
.Does(() =>
{
XUnit("./Mahapps.Metro.Tests/**/bin/" + configuration + "/*.Tests.dll",
new XUnitSettings { ToolPath = "./packages/cake/xunit.runner.console/tools/net452/xunit.console.exe" });
});

//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////

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

Task("appveyor")
.IsDependentOn("Update-SolutionInfo")
.IsDependentOn("Build")
.IsDependentOn("Unit-Tests")
.IsDependentOn("Paket-Pack")
.IsDependentOn("Zip-Demos");

//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////

RunTarget(target);
Loading

0 comments on commit 53c3f41

Please sign in to comment.