Skip to content

Commit

Permalink
Merge branch 'feature-clientEmancipation'
Browse files Browse the repository at this point in the history
  • Loading branch information
droyad committed Sep 9, 2016
2 parents 869d64e + 625d5a6 commit 4ff4e15
Show file tree
Hide file tree
Showing 572 changed files with 16,070 additions and 32,844 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*_i.c
*_p.c
Ankh.Load
Backup*
Backup*/
CVS/
PrecompiledWeb/
UpgradeLog*.*
Expand All @@ -58,3 +58,10 @@ source/packages
source/OctopusTools.v2.ncrunchsolution
*.orig
*.userprefs
*.lock.json
.vs
.vscode
/tools/
/artifacts/
/publish/
TestResult.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
<developmentDependency>true</developmentDependency>
</metadata>
<files>
<file src="init.ps1" target="tools" />
<file src="Octo.exe" target="tools" />
<file src="Octo.exe.config" target="tools" />
<file src="*" target="tools" />
</files>
</package>
File renamed without changes.
1 change: 0 additions & 1 deletion GitVersionConfig.yaml

This file was deleted.

11 changes: 11 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '{build}'
configuration: Release
platform: Any CPU
build_script:
- cmd: build.cmd
artifacts:
- path: artifacts\**\*.*
cache:
- '%USERPROFILE%\.nuget\packages'
test: off
deploy: off
207 changes: 207 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
//////////////////////////////////////////////////////////////////////
// TOOLS
//////////////////////////////////////////////////////////////////////
#tool "nuget:?package=GitVersion.CommandLine&prerelease"
#tool "nuget:?package=ILRepack"
#addin "nuget:?package=Newtonsoft.Json"
#addin "nuget:?package=SharpCompress"

using Path = System.IO.Path;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using IO = System.IO;
using SharpCompress;
using SharpCompress.Common;
using SharpCompress.Writer;

//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");

///////////////////////////////////////////////////////////////////////////////
// GLOBAL VARIABLES
///////////////////////////////////////////////////////////////////////////////
var publishDir = "./publish";
var artifactsDir = "./artifacts";
var assetDir = "./BuildAssets";
var globalAssemblyFile = "./source/Octo/Properties/AssemblyInfo.cs";
var projectToPublish = "./source/Octo";
var projectToPublishProjectJson = Path.Combine(projectToPublish, "project.json");
var octopusClientFolder = "./source/Octopus.Client";
var isContinuousIntegrationBuild = !BuildSystem.IsLocalBuild;
var octoPublishFolder = Path.Combine(publishDir, "Octo");
var octoMergedFolder = Path.Combine(publishDir, "OctoMerged");

var gitVersionInfo = GitVersion(new GitVersionSettings {
OutputType = GitVersionOutput.Json
});

var nugetVersion = gitVersionInfo.NuGetVersion;

///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////
Setup(context =>
{
Information("Building OctopusClients v{0}", nugetVersion);
});

Teardown(context =>
{
Information("Finished running tasks.");
});

//////////////////////////////////////////////////////////////////////
// PRIVATE TASKS
//////////////////////////////////////////////////////////////////////

Task("__Default")
.IsDependentOn("__Clean")
.IsDependentOn("__Restore")
.IsDependentOn("__UpdateAssemblyVersionInformation")
.IsDependentOn("__Build")
.IsDependentOn("__Test")
.IsDependentOn("__Publish")
.IsDependentOn("__PackNuget");

Task("__Clean")
.Does(() =>
{
CleanDirectory(artifactsDir);
CleanDirectory(publishDir);
CleanDirectories("./source/**/bin");
CleanDirectories("./source/**/obj");
});

Task("__Restore")
.Does(() => DotNetCoreRestore());

Task("__UpdateAssemblyVersionInformation")
.WithCriteria(isContinuousIntegrationBuild)
.Does(() =>
{
GitVersion(new GitVersionSettings {
UpdateAssemblyInfo = true,
UpdateAssemblyInfoFilePath = globalAssemblyFile
});

Information("AssemblyVersion -> {0}", gitVersionInfo.AssemblySemVer);
Information("AssemblyFileVersion -> {0}", $"{gitVersionInfo.MajorMinorPatch}.0");
Information("AssemblyInformationalVersion -> {0}", gitVersionInfo.InformationalVersion);
if(BuildSystem.IsRunningOnTeamCity)
BuildSystem.TeamCity.SetBuildNumber(gitVersionInfo.NuGetVersion);
if(BuildSystem.IsRunningOnAppVeyor)
AppVeyor.UpdateBuildVersion(gitVersionInfo.NuGetVersion);
});

Task("__Build")
.IsDependentOn("__UpdateProjectJsonVersion")
.IsDependentOn("__UpdateAssemblyVersionInformation")
.Does(() =>
{
DotNetCoreBuild("**/project.json", new DotNetCoreBuildSettings
{
Configuration = configuration
});
});

Task("__Test")
.Does(() =>
{
GetFiles("**/*Tests/project.json")
.ToList()
.ForEach(testProjectFile =>
{
DotNetCoreTest(testProjectFile.ToString(), new DotNetCoreTestSettings
{
Configuration = configuration,
WorkingDirectory = Path.GetDirectoryName(testProjectFile.ToString())
});
});
});

Task("__UpdateProjectJsonVersion")
.WithCriteria(isContinuousIntegrationBuild)
.Does(() =>
{
Information("Updating {0} version -> {1}", projectToPublishProjectJson, nugetVersion);
ModifyJson(Path.Combine(octopusClientFolder, "project.json"), json => json["version"] = nugetVersion);
ModifyJson(projectToPublishProjectJson, json => json["version"] = nugetVersion);
});

private void ModifyJson(string jsonFile, Action<JObject> modify)
{
var json = JsonConvert.DeserializeObject<JObject>(IO.File.ReadAllText(jsonFile));
modify(json);
IO.File.WriteAllText(jsonFile, JsonConvert.SerializeObject(json, Formatting.Indented));
}


Task("__Publish")
.Does(() =>
{
DotNetCorePublish(projectToPublish, new DotNetCorePublishSettings
{
Configuration = configuration,
OutputDirectory = octoPublishFolder
});
});

Task("__MergeOctoExe")
.Does(() => {
CreateDirectory(octoMergedFolder);
ILRepack(
Path.Combine(octoMergedFolder, "Octo.exe"),
Path.Combine(octoPublishFolder, "Octo.exe"),
IO.Directory.EnumerateFiles(octoPublishFolder, "*.dll").Select(f => (FilePath) f),
new ILRepackSettings {
Internalize = true,
Libs = new List<FilePath>() { octoPublishFolder }
}
);
DeleteFile(Path.Combine(octoMergedFolder, "Octo.pdb"));
CopyFileToDirectory(Path.Combine(octoPublishFolder, "Octo.exe.config"), octoMergedFolder);
});

Task("__PackNuget")
.IsDependentOn("__Publish")
.IsDependentOn("__PackOctopusToolsNuget")
.IsDependentOn("__PackClientNuget");

Task("__PackClientNuget")
.Does(() => {
DotNetCorePack(octopusClientFolder, new DotNetCorePackSettings {
Configuration = configuration,
OutputDirectory = artifactsDir
});
});

Task("__PackOctopusToolsNuget")
.IsDependentOn("__MergeOctoExe")
.Does(() => {
var nugetPackDir = Path.Combine(publishDir, "nuget");
var nuspecFile = "OctopusTools.nuspec";

CopyDirectory(octoMergedFolder, nugetPackDir);
CopyFileToDirectory(Path.Combine(assetDir, "init.ps1"), nugetPackDir);
CopyFileToDirectory(Path.Combine(assetDir, nuspecFile), nugetPackDir);

NuGetPack(Path.Combine(nugetPackDir, nuspecFile), new NuGetPackSettings {
Version = nugetVersion,
OutputDirectory = artifactsDir
});
});


//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("__Default");

//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);
25 changes: 23 additions & 2 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
@echo off
@ECHO OFF
REM see http://joshua.poehls.me/powershell-batch-file-wrapper/

PowerShell.exe -ExecutionPolicy Bypass -File "tools\Build.ps1"
SET SCRIPTNAME=%~d0%~p0%~n0.ps1
SET ARGS=%*
IF [%ARGS%] NEQ [] GOTO ESCAPE_ARGS

:POWERSHELL
PowerShell.exe -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Unrestricted -Command "& { $ErrorActionPreference = 'Stop'; & '%SCRIPTNAME%' @args; EXIT $LASTEXITCODE }" %ARGS%
EXIT /B %ERRORLEVEL%

:ESCAPE_ARGS
SET ARGS=%ARGS:"=\"%
SET ARGS=%ARGS:`=``%
SET ARGS=%ARGS:'=`'%
SET ARGS=%ARGS:$=`$%
SET ARGS=%ARGS:{=`}%
SET ARGS=%ARGS:}=`}%
SET ARGS=%ARGS:(=`(%
SET ARGS=%ARGS:)=`)%
SET ARGS=%ARGS:,=`,%
SET ARGS=%ARGS:^%=%

GOTO POWERSHELL
Loading

0 comments on commit 4ff4e15

Please sign in to comment.