Skip to content

Commit a14b5fe

Browse files
authored
Add 🍰 v0.30 (#6)
* 🍰 Add cake v0.30 * Update readme * trying to get cake to work * Add output directory * Update build to use dotnet test instead of xunit * Update build script to do a nuget pack * Update build * Typo in script * Update script * update * update appveyor * Last change
1 parent 5f0f06a commit a14b5fe

6 files changed

Lines changed: 462 additions & 0 deletions

File tree

CommandLineParser/CommandLineParser.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
<Description>Command Line Parser for .Net Core</Description>
1212
<PackageProjectUrl>https://github.com/MatthiWare/CommandLineParser.Core</PackageProjectUrl>
1313
<PackageLicenseUrl>https://github.com/MatthiWare/CommandLineParser.Core/blob/master/LICENSE</PackageLicenseUrl>
14+
<RepositoryUrl>https://github.com/MatthiWare/CommandLineParser.Core</RepositoryUrl>
15+
<PackageTags>Commandline parser</PackageTags>
1416
</PropertyGroup>
1517

1618
<ItemGroup>

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
1+
<p align="center">
2+
<a href="https://ci.appveyor.com/project/Matthiee/vcdiff-core"><img src="https://ci.appveyor.com/api/projects/status/fr1l0ktyxtofu72e?svg=true" alt="Buitld Status (AppVeyor)"></a>
3+
<a href="https://github.com/MatthiWare/CommandLineParser.Core/issues"><img src="https://img.shields.io/github/issues/MatthiWare/VCDiff.Core.svg" alt="Open Issues"></a>
4+
<a href="https://codecov.io/gh/MatthiWare/CommandLineParser.Core"><img src="https://codecov.io/gh/MatthiWare/CommandLineParser.Core/branch/master/graph/badge.svg" alt="Codecov" /></a>
5+
<a href="https://tldrlegal.com/license/apache-license-2.0-(apache-2.0)"><img src="https://img.shields.io/badge/License-AGPL%20v3-blue.svg" alt="AGPL v3"></a>
6+
</p>
7+
<p align="center">
8+
<img src="https://buildstats.info/appveyor/chart/Matthiee/CommandLineParser.Core?branch=master" />
9+
</p>
10+
111
# CommandLineParser
212
Command line parser for .Net Core

appveyor.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Operating system (build VM template)
2+
os: Visual Studio 2017
3+
4+
version: 0.1.{build}
5+
6+
# Build script
7+
build_script:
8+
- ps: .\build.ps1 --target="AppVeyor" --verbosity=Verbose
9+
10+
# artifacts
11+
artifacts:
12+
- path: 'nuget\*.nupkg'
13+
name: NuGet
14+
15+
# Tests
16+
test: off
17+
18+
init:
19+
- git config --global core.autocrlf true

build.cake

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#tool "nuget:?package=xunit.runner.console&version=2.2.0"
2+
///////////////////////////////////////////////////////////////////////////////
3+
// ARGUMENTS
4+
///////////////////////////////////////////////////////////////////////////////
5+
6+
var target = Argument("target", "Default");
7+
var configuration = Argument("configuration", "Release");
8+
9+
//////////////////////////////////////////////////////////////////////
10+
// PARAMETERS
11+
//////////////////////////////////////////////////////////////////////
12+
13+
var project = "CommandLineParser";
14+
var solution = $"./{project}.sln";
15+
var commandLineParserProjPath = $"./{project}/{project}.csproj";
16+
var tests = $"./{project}.Tests/{project}.Tests.csproj";
17+
var publishPath = MakeAbsolute(Directory("./output"));
18+
var nugetPackageDir = MakeAbsolute(Directory("./nuget"));
19+
20+
///////////////////////////////////////////////////////////////////////////////
21+
// TASKS
22+
///////////////////////////////////////////////////////////////////////////////
23+
24+
Task("Clean")
25+
.Does( () => {
26+
CleanDirectories($"./{project}/obj/**/*.*");
27+
CleanDirectories($"./{project}/bin/{configuration}/**/*.*");
28+
});
29+
30+
Task("Clean-Publish")
31+
.IsDependentOn("Clean")
32+
.Does( () => {
33+
CleanDirectory(publishPath);
34+
});
35+
36+
Task("Build")
37+
.Does(() =>
38+
{
39+
DotNetCoreBuild(solution,
40+
new DotNetCoreBuildSettings
41+
{
42+
NoRestore = false,
43+
Configuration = configuration
44+
});
45+
});
46+
47+
Task("Test")
48+
.IsDependentOn("Build")
49+
.Does( () => {
50+
51+
DotNetCoreTest(tests,
52+
new DotNetCoreTestSettings {
53+
NoBuild = true,
54+
NoRestore = true,
55+
Configuration = configuration
56+
});
57+
});
58+
59+
Task("Publish")
60+
.IsDependentOn("Test")
61+
.IsDependentOn("Clean-Publish")
62+
.Does( () => {
63+
DotNetCorePublish(solution,
64+
new DotNetCorePublishSettings {
65+
66+
NoRestore = true,
67+
Configuration = configuration,
68+
OutputDirectory = publishPath
69+
});
70+
});
71+
72+
Task("Publish-NuGet")
73+
.IsDependentOn("Publish")
74+
.Does(() =>
75+
{
76+
var nuGetPackSettings = new NuGetPackSettings
77+
{
78+
BasePath = publishPath,
79+
OutputDirectory = nugetPackageDir,
80+
Properties = new Dictionary<string, string>
81+
{
82+
{ "Configuration", configuration }
83+
}
84+
};
85+
86+
NuGetPack(commandLineParserProjPath, nuGetPackSettings);
87+
88+
});
89+
90+
Task("Default")
91+
.IsDependentOn("Test");
92+
93+
Task("AppVeyor")
94+
.IsDependentOn("Publish-NuGet");
95+
96+
RunTarget(target);

build.ps1

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
##########################################################################
2+
# This is the Cake bootstrapper script for PowerShell.
3+
# This file was downloaded from https://github.com/cake-build/resources
4+
# Feel free to change this file to fit your needs.
5+
##########################################################################
6+
7+
<#
8+
9+
.SYNOPSIS
10+
This is a Powershell script to bootstrap a Cake build.
11+
12+
.DESCRIPTION
13+
This Powershell script will download NuGet if missing, restore NuGet tools (including Cake)
14+
and execute your Cake build script with the parameters you provide.
15+
16+
.PARAMETER Script
17+
The build script to execute.
18+
.PARAMETER Target
19+
The build script target to run.
20+
.PARAMETER Configuration
21+
The build configuration to use.
22+
.PARAMETER Verbosity
23+
Specifies the amount of information to be displayed.
24+
.PARAMETER ShowDescription
25+
Shows description about tasks.
26+
.PARAMETER DryRun
27+
Performs a dry run.
28+
.PARAMETER Experimental
29+
Uses the nightly builds of the Roslyn script engine.
30+
.PARAMETER Mono
31+
Uses the Mono Compiler rather than the Roslyn script engine.
32+
.PARAMETER SkipToolPackageRestore
33+
Skips restoring of packages.
34+
.PARAMETER ScriptArgs
35+
Remaining arguments are added here.
36+
37+
.LINK
38+
https://cakebuild.net
39+
40+
#>
41+
42+
[CmdletBinding()]
43+
Param(
44+
[string]$Script = "build.cake",
45+
[string]$Target,
46+
[string]$Configuration,
47+
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
48+
[string]$Verbosity,
49+
[switch]$ShowDescription,
50+
[Alias("WhatIf", "Noop")]
51+
[switch]$DryRun,
52+
[switch]$Experimental,
53+
[switch]$Mono,
54+
[switch]$SkipToolPackageRestore,
55+
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
56+
[string[]]$ScriptArgs
57+
)
58+
59+
[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
60+
function MD5HashFile([string] $filePath)
61+
{
62+
if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf))
63+
{
64+
return $null
65+
}
66+
67+
[System.IO.Stream] $file = $null;
68+
[System.Security.Cryptography.MD5] $md5 = $null;
69+
try
70+
{
71+
$md5 = [System.Security.Cryptography.MD5]::Create()
72+
$file = [System.IO.File]::OpenRead($filePath)
73+
return [System.BitConverter]::ToString($md5.ComputeHash($file))
74+
}
75+
finally
76+
{
77+
if ($file -ne $null)
78+
{
79+
$file.Dispose()
80+
}
81+
}
82+
}
83+
84+
function GetProxyEnabledWebClient
85+
{
86+
$wc = New-Object System.Net.WebClient
87+
$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
88+
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
89+
$wc.Proxy = $proxy
90+
return $wc
91+
}
92+
93+
Write-Host "Preparing to run build script..."
94+
95+
if(!$PSScriptRoot){
96+
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
97+
}
98+
99+
$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
100+
$ADDINS_DIR = Join-Path $TOOLS_DIR "Addins"
101+
$MODULES_DIR = Join-Path $TOOLS_DIR "Modules"
102+
$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
103+
$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe"
104+
$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
105+
$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config"
106+
$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum"
107+
$ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config"
108+
$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config"
109+
110+
# Make sure tools folder exists
111+
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
112+
Write-Verbose -Message "Creating tools directory..."
113+
New-Item -Path $TOOLS_DIR -Type directory | out-null
114+
}
115+
116+
# Make sure that packages.config exist.
117+
if (!(Test-Path $PACKAGES_CONFIG)) {
118+
Write-Verbose -Message "Downloading packages.config..."
119+
try {
120+
$wc = GetProxyEnabledWebClient
121+
$wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch {
122+
Throw "Could not download packages.config."
123+
}
124+
}
125+
126+
# Try find NuGet.exe in path if not exists
127+
if (!(Test-Path $NUGET_EXE)) {
128+
Write-Verbose -Message "Trying to find nuget.exe in PATH..."
129+
$existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) }
130+
$NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1
131+
if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) {
132+
Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)."
133+
$NUGET_EXE = $NUGET_EXE_IN_PATH.FullName
134+
}
135+
}
136+
137+
# Try download NuGet.exe if not exists
138+
if (!(Test-Path $NUGET_EXE)) {
139+
Write-Verbose -Message "Downloading NuGet.exe..."
140+
try {
141+
$wc = GetProxyEnabledWebClient
142+
$wc.DownloadFile($NUGET_URL, $NUGET_EXE)
143+
} catch {
144+
Throw "Could not download NuGet.exe."
145+
}
146+
}
147+
148+
# Save nuget.exe path to environment to be available to child processed
149+
$ENV:NUGET_EXE = $NUGET_EXE
150+
151+
# Restore tools from NuGet?
152+
if(-Not $SkipToolPackageRestore.IsPresent) {
153+
Push-Location
154+
Set-Location $TOOLS_DIR
155+
156+
# Check for changes in packages.config and remove installed tools if true.
157+
[string] $md5Hash = MD5HashFile($PACKAGES_CONFIG)
158+
if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
159+
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
160+
Write-Verbose -Message "Missing or changed package.config hash..."
161+
Remove-Item * -Recurse -Exclude packages.config,nuget.exe
162+
}
163+
164+
Write-Verbose -Message "Restoring tools from NuGet..."
165+
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
166+
167+
if ($LASTEXITCODE -ne 0) {
168+
Throw "An error occurred while restoring NuGet tools."
169+
}
170+
else
171+
{
172+
$md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
173+
}
174+
Write-Verbose -Message ($NuGetOutput | out-string)
175+
176+
Pop-Location
177+
}
178+
179+
# Restore addins from NuGet
180+
if (Test-Path $ADDINS_PACKAGES_CONFIG) {
181+
Push-Location
182+
Set-Location $ADDINS_DIR
183+
184+
Write-Verbose -Message "Restoring addins from NuGet..."
185+
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""
186+
187+
if ($LASTEXITCODE -ne 0) {
188+
Throw "An error occurred while restoring NuGet addins."
189+
}
190+
191+
Write-Verbose -Message ($NuGetOutput | out-string)
192+
193+
Pop-Location
194+
}
195+
196+
# Restore modules from NuGet
197+
if (Test-Path $MODULES_PACKAGES_CONFIG) {
198+
Push-Location
199+
Set-Location $MODULES_DIR
200+
201+
Write-Verbose -Message "Restoring modules from NuGet..."
202+
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""
203+
204+
if ($LASTEXITCODE -ne 0) {
205+
Throw "An error occurred while restoring NuGet modules."
206+
}
207+
208+
Write-Verbose -Message ($NuGetOutput | out-string)
209+
210+
Pop-Location
211+
}
212+
213+
# Make sure that Cake has been installed.
214+
if (!(Test-Path $CAKE_EXE)) {
215+
Throw "Could not find Cake.exe at $CAKE_EXE"
216+
}
217+
218+
219+
220+
# Build Cake arguments
221+
$cakeArguments = @("$Script");
222+
if ($Target) { $cakeArguments += "-target=$Target" }
223+
if ($Configuration) { $cakeArguments += "-configuration=$Configuration" }
224+
if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" }
225+
if ($ShowDescription) { $cakeArguments += "-showdescription" }
226+
if ($DryRun) { $cakeArguments += "-dryrun" }
227+
if ($Experimental) { $cakeArguments += "-experimental" }
228+
if ($Mono) { $cakeArguments += "-mono" }
229+
$cakeArguments += $ScriptArgs
230+
231+
# Start Cake
232+
Write-Host "Running build script..."
233+
&$CAKE_EXE $cakeArguments
234+
exit $LASTEXITCODE

0 commit comments

Comments
 (0)