Skip to content

Commit

Permalink
Merge pull request #4 from thomaslevesque/build-script
Browse files Browse the repository at this point in the history
Build script, AppVeyor settings
  • Loading branch information
thomaslevesque authored Sep 23, 2018
2 parents 90d2bae + 1c36d8b commit e45c36e
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ obj/
.vscode/
*.user

artifacts/

_ReSharper.Caches/
28 changes: 8 additions & 20 deletions AspNetCore.AsyncInitialization.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,51 +14,39 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{ACEAE2B6-8261-4C7F-968F-35D5221929D6}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
build.cmd = build.cmd
LICENSE.txt = LICENSE.txt
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{C6A2E948-78A9-4E82-B112-A00F93A94496}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "build", "tools\build\build.csproj", "{191B7D1C-7505-404B-8805-DD8E3EB44785}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DEC4A732-9A80-4CC9-9775-D3A8CE65F633}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DEC4A732-9A80-4CC9-9775-D3A8CE65F633}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DEC4A732-9A80-4CC9-9775-D3A8CE65F633}.Debug|x64.ActiveCfg = Debug|Any CPU
{DEC4A732-9A80-4CC9-9775-D3A8CE65F633}.Debug|x64.Build.0 = Debug|Any CPU
{DEC4A732-9A80-4CC9-9775-D3A8CE65F633}.Debug|x86.ActiveCfg = Debug|Any CPU
{DEC4A732-9A80-4CC9-9775-D3A8CE65F633}.Debug|x86.Build.0 = Debug|Any CPU
{DEC4A732-9A80-4CC9-9775-D3A8CE65F633}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DEC4A732-9A80-4CC9-9775-D3A8CE65F633}.Release|Any CPU.Build.0 = Release|Any CPU
{DEC4A732-9A80-4CC9-9775-D3A8CE65F633}.Release|x64.ActiveCfg = Release|Any CPU
{DEC4A732-9A80-4CC9-9775-D3A8CE65F633}.Release|x64.Build.0 = Release|Any CPU
{DEC4A732-9A80-4CC9-9775-D3A8CE65F633}.Release|x86.ActiveCfg = Release|Any CPU
{DEC4A732-9A80-4CC9-9775-D3A8CE65F633}.Release|x86.Build.0 = Release|Any CPU
{8264807E-AEEC-4A9F-8023-7B30B01F3FD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8264807E-AEEC-4A9F-8023-7B30B01F3FD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8264807E-AEEC-4A9F-8023-7B30B01F3FD2}.Debug|x64.ActiveCfg = Debug|Any CPU
{8264807E-AEEC-4A9F-8023-7B30B01F3FD2}.Debug|x64.Build.0 = Debug|Any CPU
{8264807E-AEEC-4A9F-8023-7B30B01F3FD2}.Debug|x86.ActiveCfg = Debug|Any CPU
{8264807E-AEEC-4A9F-8023-7B30B01F3FD2}.Debug|x86.Build.0 = Debug|Any CPU
{8264807E-AEEC-4A9F-8023-7B30B01F3FD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8264807E-AEEC-4A9F-8023-7B30B01F3FD2}.Release|Any CPU.Build.0 = Release|Any CPU
{8264807E-AEEC-4A9F-8023-7B30B01F3FD2}.Release|x64.ActiveCfg = Release|Any CPU
{8264807E-AEEC-4A9F-8023-7B30B01F3FD2}.Release|x64.Build.0 = Release|Any CPU
{8264807E-AEEC-4A9F-8023-7B30B01F3FD2}.Release|x86.ActiveCfg = Release|Any CPU
{8264807E-AEEC-4A9F-8023-7B30B01F3FD2}.Release|x86.Build.0 = Release|Any CPU
{191B7D1C-7505-404B-8805-DD8E3EB44785}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{191B7D1C-7505-404B-8805-DD8E3EB44785}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{DEC4A732-9A80-4CC9-9775-D3A8CE65F633} = {F3949869-0B22-4F63-8B97-B3548E7ED0AC}
{8264807E-AEEC-4A9F-8023-7B30B01F3FD2} = {81FBB26C-5751-4F6E-8B10-4BD7AC3888FC}
{191B7D1C-7505-404B-8805-DD8E3EB44785} = {C6A2E948-78A9-4E82-B112-A00F93A94496}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2CD1AD1C-0AF7-48E4-A9DE-4D22491B7292}
Expand Down
17 changes: 17 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '{build}'
image: Visual Studio 2017

pull_requests:
do_not_increment_build_number: true

build_script:
- cmd: build.cmd

on_failure:
- ps: $root = (Resolve-Path artifacts); [IO.Directory]::GetFiles($root.Path, '*.*', 'AllDirectories') | % { Push-AppveyorArtifact $_ -FileName $_.Substring($root.Path.Length + 1) -DeploymentName failed-build }

nuget:
disable_publish_on_pr: true

artifacts:
- path: .\artifacts\*\*
1 change: 1 addition & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@dotnet run --project %~dp0\tools\build\build.csproj -- %*
89 changes: 89 additions & 0 deletions tools/build/Build.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using System.IO;
using System.Runtime.CompilerServices;
using McMaster.Extensions.CommandLineUtils;
using static Bullseye.Targets;
using static SimpleExec.Command;

namespace build
{
[Command(ThrowOnUnexpectedArgument = false)]
[SuppressDefaultHelpOption]
class Build
{
static void Main(string[] args) =>
CommandLineApplication.Execute<Build>(args);

[Option("-h|-?|--help", "Show help message", CommandOptionType.NoValue)]
public bool ShowHelp { get; } = false;

[Option("-v|--version", "The version to build", CommandOptionType.SingleValue)]
public string Version { get; } = "0.0.0";

[Option("-c|--configuration", "The configuration to build", CommandOptionType.SingleValue)]
public string Configuration { get; } = "Release";

public string[] RemainingArguments { get; } = null;

public void OnExecute(CommandLineApplication app)
{
if (ShowHelp)
{
app.ShowHelp();
app.Out.WriteLine("Bullseye help:");
app.Out.WriteLine();
RunTargets(new[] { "-h" });
return;
}

Directory.SetCurrentDirectory(GetSolutionDirectory());

string artifactsDir = Path.GetFullPath("artifacts");
string logsDir = Path.Combine(artifactsDir, "logs");
string buildLogFile = Path.Combine(logsDir, "build.binlog");
string packagesDir = Path.Combine(artifactsDir, "packages");

string solutionFile = "AspNetCore.AsyncInitialization.sln";
string libraryProject = "src/AspNetCore.AsyncInitialization/AspNetCore.AsyncInitialization.csproj";
string testProject = "tests/AspNetCore.AsyncInitialization.Tests/AspNetCore.AsyncInitialization.Tests.csproj";

Target(
"artifactDirectories",
() =>
{
Directory.CreateDirectory(artifactsDir);
Directory.CreateDirectory(logsDir);
Directory.CreateDirectory(packagesDir);
});

Target(
"build",
DependsOn("artifactDirectories"),
() => Run(
"dotnet",
$"build -c \"{Configuration}\" /p:Version=\"{Version}\" /bl:\"{buildLogFile}\" \"{solutionFile}\""));

Target(
"test",
DependsOn("build"),
() => Run(
"dotnet",
$"test -c \"{Configuration}\" --no-build \"{testProject}\""));

Target(
"pack",
DependsOn("artifactDirectories", "build"),
() => Run(
"dotnet",
$"pack -c \"{Configuration}\" --no-build /p:Version=\"{Version}\" -o \"{packagesDir}\" \"{libraryProject}\""));

Target("default", DependsOn("test", "pack"));

RunTargets(RemainingArguments);
}

private static string GetSolutionDirectory() =>
Path.GetFullPath(Path.Combine(GetScriptDirectory(), @"..\.."));

private static string GetScriptDirectory([CallerFilePath] string filename = null) => Path.GetDirectoryName(filename);
}
}
14 changes: 14 additions & 0 deletions tools/build/build.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bullseye" Version="1.3.0" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.2.5" />
<PackageReference Include="SimpleExec" Version="3.0.0" />
</ItemGroup>

</Project>

0 comments on commit e45c36e

Please sign in to comment.