Skip to content

Commit

Permalink
Infrastructure and statistics related items.
Browse files Browse the repository at this point in the history
  • Loading branch information
jordansjones committed Feb 19, 2015
1 parent 439bd29 commit fb4ed8e
Show file tree
Hide file tree
Showing 28 changed files with 1,154 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
48 changes: 48 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# Build results
Expand Down Expand Up @@ -181,3 +182,50 @@ UpgradeLog*.htm

# Microsoft Fakes
FakesAssemblies/

# =========================
# Operating System Files
# =========================

# OSX
# =========================

.DS_Store
.AppleDouble
.LSOverride

# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Windows
# =========================

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk
37 changes: 37 additions & 0 deletions Draft.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Draft-Net45", "source\Draft\Draft-Net45.csproj", "{A4D60581-25BF-4DE9-877C-4179B3F0747C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Draft-Net45.Tests", "tests\Draft.Tests\Draft-Net45.Tests.csproj", "{3F288474-3C7C-4AFA-BE4F-794F32720F9A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "meta", "meta", "{EC663AEE-1976-42DC-94DE-3046D3CE16AD}"
ProjectSection(SolutionItems) = preProject
meta\Draft.nuspec = meta\Draft.nuspec
LICENSE.txt = LICENSE.txt
README.md = README.md
ReleaseNotes.md = ReleaseNotes.md
meta\SolutionInfo.cs = meta\SolutionInfo.cs
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A4D60581-25BF-4DE9-877C-4179B3F0747C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4D60581-25BF-4DE9-877C-4179B3F0747C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4D60581-25BF-4DE9-877C-4179B3F0747C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4D60581-25BF-4DE9-877C-4179B3F0747C}.Release|Any CPU.Build.0 = Release|Any CPU
{3F288474-3C7C-4AFA-BE4F-794F32720F9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F288474-3C7C-4AFA-BE4F-794F32720F9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F288474-3C7C-4AFA-BE4F-794F32720F9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F288474-3C7C-4AFA-BE4F-794F32720F9A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
File renamed without changes.
2 changes: 2 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### New in 0.1.0 (Released 2015/02/20)
* Initial release
211 changes: 211 additions & 0 deletions build.csx
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////

var target = Argument<string>("target", "Default");
var configuration = Argument<string>("configuration", "Debug");
var forcePackage = HasArgument("forcePackage");

///////////////////////////////////////////////////////////////////////////////
// GLOBAL VARIABLES
///////////////////////////////////////////////////////////////////////////////

var projectName = "Draft";

// "Root"
var context = GetContext();
var baseDir = context.Environment.WorkingDirectory;
var solution = baseDir.GetFilePath(projectName + ".sln");

// Directories
// WorkingDirectory is relative to this file. Make it relative to the Solution file.
var solutionDir = solution.GetDirectory();
var packagingRoot = baseDir.Combine("publish");
var testResultsDir = baseDir.Combine("TestResults");
var nugetPackagingDir = packagingRoot.Combine(projectName);
var sourcesDir = solutionDir.Combine("src");
var testsDir = solutionDir.Combine("tests");
var metaDir = solutionDir.Combine("meta");

// Files
var solutionInfoCs = metaDir.GetFilePath("SolutionInfo.cs");
var nuspecFile = metaDir.GetFilePath(projectName + ".nuspec");
var licenseFile = solutionDir.GetFilePath("LICENSE.txt");
var readmeFile = solutionDir.GetFilePath("README.md");
var releaseNotesFile = solutionDir.GetFilePath("ReleaseNotes.md");

var appVeyorEnv = context.AppVeyor().Environment;

// Get whether or not this is a local build.
var local = !context.BuildSystem().IsRunningOnAppVeyor;
var isReleaseBuild = !local && appVeyorEnv.Repository.Tag.IsTag;

// Release notes
var releaseNotes = ParseReleaseNotes(releaseNotesFile);

// Version
var buildNumber = !isReleaseBuild ? 0 : appVeyorEnv.Build.Number;
var version = releaseNotes.Version.ToString();
var semVersion = isReleaseBuild ? version : (version + string.Concat("-build-", buildNumber));

///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////

Setup(() =>
{
// Executed BEFORE the first task.
Information("Running tasks...");

if (!FileSystem.Exist(testResultsDir))
{
CreateDirectory(testResultsDir);
}
if (!FileSystem.Exist(nugetPackagingDir))
{
CreateDirectory(nugetPackagingDir);
}
});

Teardown(() =>
{
// Executed AFTER the last task.
Information("Finished running tasks.");
});

///////////////////////////////////////////////////////////////////////////////
// TASK DEFINITIONS
///////////////////////////////////////////////////////////////////////////////

Task("Clean")
.Does(() =>
{
// Clean Solution directories
Information("Cleaning {0}", solutionDir);
CleanDirectories(solutionDir + "/packages");
CleanDirectories(solutionDir + "/**/bin/" + configuration);
CleanDirectories(solutionDir + "/**/obj/" + configuration);

foreach (var dir in new [] { packagingRoot, testResultsDir })
{
Information("Cleaning {0}", dir);
CleanDirectory(dir);
}
});

Task("Restore")
.IsDependentOn("Clean")
.Does(() =>
{
Information("Restoring {0}", solution);
NuGetRestore(solution);
});

Task("AssemblyInfo")
.IsDependentOn("Restore")
.WithCriteria(() => !isReleaseBuild)
.Does(() =>
{
Information("Creating {0} - Version: {1}", solutionInfoCs, version);
CreateAssemblyInfo(solutionInfoCs, new AssemblyInfoSettings {
Product = projectName,
Version = version,
FileVersion = version,
InformationalVersion = semVersion
});
});

Task("Build")
.IsDependentOn("AssemblyInfo")
.Does(() =>
{
Information("Building {0}", solution);
MSBuild(solution, settings =>
settings.SetConfiguration(configuration)
);
});

Task("UnitTests")
.IsDependentOn("Build")
.Does(() =>
{
Information("Running Tests in {0}", solution);

XUnit2(
solutionDir + "/**/bin/" + configuration + "/**/*.Tests*.dll",
new XUnit2Settings {
OutputDirectory = testResultsDir,
HtmlReport = true,
XmlReport = true
}
);
});

Task("CopyNugetPackageFiles")
.IsDependentOn("UnitTests")
.Does(() =>
{

var baseBuildDir = sourcesDir.Combine(projectName).Combine("bin").Combine(configuration);

var net45BuildDir = baseBuildDir.Combine("Net45");
var net45PackageDir = nugetPackagingDir.Combine("lib/net45/");

var dirMap = new Dictionary<DirectoryPath, DirectoryPath> {
{ net45BuildDir, net45PackageDir }
};

CleanDirectories(dirMap.Values);

foreach (var dirPair in dirMap)
{
var files = FileSystem.GetDirectory(dirPair.Key)
.GetFiles(projectName + "*", SearchScope.Current)
.Select(x => x.Path);
CopyFiles(files, dirPair.Value);
}

var packageFiles = new FilePath[] {
licenseFile,
readmeFile,
releaseNotesFile
};

CopyFiles(packageFiles, nugetPackagingDir);
});

Task("CreateNugetPackage")
.IsDependentOn("CopyNugetPackageFiles")
.Does(() =>
{
NuGetPack(
nuspecFile,
new NuGetPackSettings {
Version = semVersion,
ReleaseNotes = releaseNotes.Notes.ToArray(),
BasePath = nugetPackagingDir,
OutputDirectory = packagingRoot,
Symbols = false,
NoPackageAnalysis = false
}
);
});

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

Task("Package")
.IsDependentOn("CreateNugetPackage")
.WithCriteria(() => isReleaseBuild || forcePackage);

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

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

Information("Building {0} [{1}] ({2} - {3}).", solution.GetFilename(), configuration, version, semVersion);

RunTarget(target);
47 changes: 47 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Param(
[string] $Target = "Default",
[string] $Configuration = "Debug",
[string] $Verbosity = "normal",
[switch] $ForcePackage
)

$SelfRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
$Script = Join-Path $SelfRoot "build.csx"

$TOOLS_DIR = Join-Path $SelfRoot "tools"
$CAKE_DIR = Join-Path $TOOLS_DIR "Cake"
$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
$CAKE_EXE = Join-Path $CAKE_DIR "Cake.exe"

if (!(Test-Path $NUGET_EXE)) {
Throw "Could not find " + $NUGET_EXE
}

Invoke-Expression "$NUGET_EXE install xunit.runners -OutputDirectory $TOOLS_DIR -ExcludeVersion -Prerelease"
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}

Invoke-Expression "$NUGET_EXE install ilmerge -OutputDirectory $TOOLS_DIR -ExcludeVersion -Prerelease"
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}

Invoke-Expression "$NUGET_EXE install Cake -OutputDirectory $TOOLS_DIR -ExcludeVersion"
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}

if (!(Test-Path $CAKE_EXE)) {
Throw "Could not find " + $CAKE_EXE
}

$ForcePackageArg = ""
if ($ForcePackage)
{
$ForcePackageArg = "-forcePackage"
}

Invoke-Expression "$CAKE_EXE `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $ForcePackageArg"

exit $LASTEXITCODE
20 changes: 20 additions & 0 deletions meta/Draft.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Draft</id>
<title>Draft</title>
<version>@version@</version>
<authors>Jordan S. Jones</authors>
<licenseUrl>https://raw.githubusercontent.com/jordansjones/Draft/master/LICENSE.txt</licenseUrl>
<projectUrl>https://github.com/jordansjones/Draft</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>An etcd client library for .Net</description>
<releaseNotes>@releaseNotes@</releaseNotes>
<tags>etcd</tags>
<copyright>Copyright 2015 Jordan S. Jones</copyright>
</metadata>
<files>
<file src="lib\net45\Draft.*" target="lib\net45" />
<file src="*.*" exclude="lib\**\*.*" />
</files>
</package>
Loading

0 comments on commit fb4ed8e

Please sign in to comment.