Skip to content
This repository has been archived by the owner on Mar 2, 2021. It is now read-only.

Commit

Permalink
swap rake for simple-targets-csx
Browse files Browse the repository at this point in the history
  • Loading branch information
adamralph committed Nov 17, 2016
1 parent 848c035 commit 8fe398d
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 169 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Expand Up @@ -12,5 +12,8 @@ max_line_length = 120
[*.cs]
indent_size = 4

[*.csx]
indent_size = 4

[*.cmd]
max_line_length = 9999
3 changes: 2 additions & 1 deletion .nuget/packages.config
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="xunit.runners" version="1.9.2" />
</packages>
<package id="simple-targets-csx" version="5.0.0" />
</packages>
4 changes: 0 additions & 4 deletions Gemfile

This file was deleted.

20 changes: 0 additions & 20 deletions Gemfile.lock

This file was deleted.

14 changes: 11 additions & 3 deletions README.md
Expand Up @@ -10,9 +10,7 @@ The guard clause library which stands out from the crowd like the faintest passi

You'll hardly know it's there!

Get it at [NuGet](https://nuget.org/packages?q=liteguard "LiteGuard on NuGet").

To build from source, clone or fork this repository and see ['How to build'](/how_to_build.md).
Get it from [NuGet](https://nuget.org/packages?q=liteguard "LiteGuard on NuGet") or [build from source](#build-from-source).

## Usage

Expand Down Expand Up @@ -67,6 +65,16 @@ Many guard clause libraries provide a huge range of methods for determining whet

In my opinion, it is not the job of a guard clause library to validate arguments against business rules. I believe the role of a guard clause library is to prevent method calls with null arguments or null argument values. Ideally, I'd like such things to be built into .NET languages. If that ever happens I will happily allow LiteGuard to retire gracefully to a small but comfortable home near the seaside with a carriage clock and a little Havanese.

## Build from source

Clone this repo, navigate to your clone folder and execute `build.cmd`. The only prerequisite you need is MSBuild 14, which is also included in Visual Studio 2015.

`build.cmd` executes the default build targets which include compilation, test execution and packaging. After the build has completed, the build artifacts will be located in `artifacts/output/`.

For full usage details for `build.cmd`, execute `build.cmd -?`. See [simple-targets-csx](https://github.com/adamralph/simple-targets-csx) for more info.

You can also build the solution using Visual Studio 2015 or later. At the time of writing the build is only confirmed to work on Windows.

## Can I help to improve it and/or fix bugs?

Absolutely! Please feel free to raise issues, fork the source code, send pull requests, etc.
Expand Down
9 changes: 4 additions & 5 deletions appveyor.yml
Expand Up @@ -6,14 +6,13 @@ branches:
- master
skip_tags: true
environment:
PATH: 'C:\Ruby200\bin;%PATH%'
BUILD: $(APPVEYOR_BUILD_NUMBER)
install:
- cmd: bundle install
BUILD_NUMBER: $(APPVEYOR_BUILD_NUMBER)
build_script:
- cmd: build.cmd
nuget:
disable_publish_on_pr: true
test: off
artifacts:
- path: ./artifacts/*/*.*
- path: artifacts/*/*.*
- path: tests/**/*TestResults.*
deploy: off
2 changes: 1 addition & 1 deletion build.cmd
Expand Up @@ -26,4 +26,4 @@ if not exist .nuget\NuGet.exe (
.nuget\NuGet.exe restore .\LiteGuard.sln -MSBuildVersion 14

:: run script
call bundle exec rake %*
"%ProgramFiles(x86)%\MSBuild\14.0\Bin\csi.exe" .\build.csx %*
110 changes: 110 additions & 0 deletions build.csx
@@ -0,0 +1,110 @@
#load "packages/simple-targets-csx.5.0.0/simple-targets.csx"

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using static SimpleTargets;

// version
var versionSuffix = Environment.GetEnvironmentVariable("VERSION_SUFFIX") ?? "";
var buildNumber = Environment.GetEnvironmentVariable("BUILD_NUMBER") ?? "000000";
var buildNumberSuffix = versionSuffix == "" ? "" : "-build" + buildNumber;
var version = File.ReadAllText("src/LiteGuard/Properties/CommonAssemblyInfo.cs")
.Split(new[] { "AssemblyInformationalVersion(\"" }, 2, StringSplitOptions.RemoveEmptyEntries)[1]
.Split('\"').First() + versionSuffix + buildNumberSuffix;

// locations
var solution = "./LiteGuard.sln";
var logs = "./artifacts/logs";
var msBuild = $"{Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)}/MSBuild/14.0/Bin/msbuild.exe";
var nuspecs = new[] { "./src/LiteGuard.nuspec", "./src/LiteGuard.Source.nuspec", };
var output = "./artifacts/output";
var nuget = "./.nuget/NuGet.exe";
var xunit = "packages/xunit.runners.1.9.2/tools/xunit.console.clr4.exe";
var acceptanceTests = new[]
{
Path.GetFullPath("tests/LiteGuard.Test.Acceptance.net35/bin/Release/LiteGuard.Test.Acceptance.net35.dll"),
Path.GetFullPath("tests/LiteGuard.Test.Acceptance.net45/bin/Release/LiteGuard.Test.Acceptance.net45.dll"),
};

// targets
var targets = new TargetDictionary();

targets.Add("default", DependsOn("pack", "accept"));

targets.Add("logs", () => Directory.CreateDirectory(logs));

targets.Add(
"build",
DependsOn("logs"),
() => Cmd(
msBuild,
$"{solution} /p:Configuration=Release /nologo /m /v:m /nr:false " +
$"/fl /flp:LogFile={logs}/msbuild.log;Verbosity=Detailed;PerformanceSummary"));

targets.Add("output", () => Directory.CreateDirectory(output));

targets.Add(
"src",
() =>
{
// {platform}, {src}
var platforms = new Dictionary<string, string>
{
{ "net35", "net35" },
{ "netstandard1.0", "" },
};
foreach (var platform in platforms)
{
var originalSource = File.ReadAllText($"src/LiteGuard.{platform.Value}/Guard.cs");
var modifiedSource = originalSource
.Replace("namespace LiteGuard", "namespace $rootnamespace$")
.Replace("public static class", "internal static class");
Directory.CreateDirectory($"src/contentFiles/cs/{platform.Key}");
File.WriteAllText($"src/contentFiles/cs/{platform.Key}/Guard.cs.pp", modifiedSource);
}
});

targets.Add(
"pack",
DependsOn("build", "src", "output"),
() =>
{
foreach (var nuspec in nuspecs)
{
Cmd(nuget, $"pack {nuspec} -Version {version} -OutputDirectory {output} -NoPackageAnalysis");
}
});

targets.Add(
"accept",
DependsOn("build"),
() =>
{
foreach (var acceptanceTest in acceptanceTests)
{
Cmd(xunit, $"{acceptanceTest} /html {acceptanceTest}.TestResults.html /xml {acceptanceTest}.TestResults.xml");
}
});

Run(Args, targets);

// helper
public static void Cmd(string fileName, string args)
{
using (var process = new Process())
{
process.StartInfo = new ProcessStartInfo { FileName = $"\"{fileName}\"", Arguments = args, UseShellExecute = false, };
Console.WriteLine($"Running '{process.StartInfo.FileName} {process.StartInfo.Arguments}'...");
process.Start();
process.WaitForExit();
if (process.ExitCode != 0)
{
throw new InvalidOperationException($"The command exited with code {process.ExitCode}.");
}
}
}
54 changes: 0 additions & 54 deletions how_to_build.md

This file was deleted.

81 changes: 0 additions & 81 deletions rakefile.rb

This file was deleted.

0 comments on commit 8fe398d

Please sign in to comment.