Skip to content

Commit

Permalink
Added appveyor, cake, nuget
Browse files Browse the repository at this point in the history
  • Loading branch information
Baklap4 committed May 30, 2017
1 parent ac6dbb0 commit 939d7cc
Show file tree
Hide file tree
Showing 11 changed files with 359 additions and 8 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# DotNetLocalizer

AppVeyor:

[![Build status](https://ci.appveyor.com/api/projects/status/6lshcksp3oh9craj?svg=true)](https://ci.appveyor.com/project/Baklap4/dotnetlocalizer)

# TBA .....
15 changes: 15 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 1.0.{build}
pull_requests:
do_not_increment_build_number: true
build_script:
- ps: '& ./build.ps1 -target pack'
test_script:
- ps: '& ./build.ps1 -target test'
artifacts:
- path: output\*.nupkg
name: NuGet
deploy:
- provider: Environment
name: NuGet
on:
branch: master
91 changes: 91 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#addin "Cake.Powershell"

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

var versionSuffix = "nuget-test";

var isRunningOnAppVeyor = AppVeyor.IsRunningOnAppVeyor;

Task("Clean")
.Does(() =>
{
CleanDirectories("./src/**/bin");
CleanDirectories("./src/**/obj");
});

Task("Restore")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetCoreRestore("./src/DotNetLocalizer.Core");
DotNetCoreRestore("./src/DotNetLocalizer.Json");
DotNetCoreRestore("./src/DotNetLocalizer.Yaml");
});

Task("Build")
.IsDependentOn("Restore")
.Does(() =>
{
var settings = new DotNetCoreBuildSettings
{
Configuration = configuration,
VersionSuffix = versionSuffix
};

DotNetCoreBuild("./src/DotNetLocalizer.Core", settings);
DotNetCoreBuild("./src/DotNetLocalizer.Json", settings);
DotNetCoreBuild("./src/DotNetLocalizer.Yaml", settings);
});

Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
// TODO
});

Task("Version")
.Does(() =>
{
if (!isRunningOnAppVeyor)
{
throw new InvalidOperationException("Can only set version when running on AppVeyor");
}

var version = AppVeyor.Environment.Build.Version;

StartPowershellFile("./update-version.ps1", args =>
{
args.Append("projectFile", "./src/DotNetLocalizer.Core/DotNetLocalizer.Core.csproj").Append("version", version);
});
StartPowershellFile("./update-version.ps1", args =>
{
args.Append("projectFile", "./src/DotNetLocalizer.Json/DotNetLocalizer.Json.csproj").Append("version", version);
});
StartPowershellFile("./update-version.ps1", args =>
{
args.Append("projectFile", "./src/DotNetLocalizer.Yaml/DotNetLocalizer.Yaml.csproj").Append("version", version);
});
});

Task("Pack")
.IsDependentOn("Version")
.IsDependentOn("Build")
.Does(() =>
{
var settings = new DotNetCorePackSettings
{
Configuration = "Release",
OutputDirectory = "./output/"
};

DotNetCorePack("./src/DotNetLocalizer.Core", settings);
DotNetCorePack("./src/DotNetLocalizer.Json", settings);
DotNetCorePack("./src/DotNetLocalizer.Yaml", settings);
});

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

RunTarget(target);
140 changes: 140 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<#
.SYNOPSIS
This is a Powershell script to bootstrap a Cake build.
.DESCRIPTION
This Powershell script will download NuGet if missing, restore NuGet tools (including Cake)
and execute your Cake build script with the parameters you provide.
.PARAMETER Script
The build script to execute.
.PARAMETER Target
The build script target to run.
.PARAMETER Configuration
The build configuration to use.
.PARAMETER Verbosity
Specifies the amount of information to be displayed.
.PARAMETER Experimental
Tells Cake to use the latest Roslyn release.
.PARAMETER WhatIf
Performs a dry run of the build script.
No tasks will be executed.
.PARAMETER Mono
Tells Cake to use the Mono scripting engine.
.LINK
http://cakebuild.net
#>

[CmdletBinding()]
Param(
[string]$Script = "build.cake",
[string]$Target = "Default",
[string]$Configuration = "Release",
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
[string]$Verbosity = "Verbose",
[switch]$Experimental,
[Alias("DryRun","Noop")]
[switch]$WhatIf,
[switch]$Mono,
[switch]$SkipToolPackageRestore,
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$ScriptArgs
)

Write-Host "Preparing to run build script..."

$PS_SCRIPT_ROOT = split-path -parent $MyInvocation.MyCommand.Definition;
$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
$NUGET_URL = "http://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe"
$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config"

# Should we use mono?
$UseMono = "";
if($Mono.IsPresent) {
Write-Verbose -Message "Using the Mono based scripting engine."
$UseMono = "-mono"
}

# Should we use the new Roslyn?
$UseExperimental = "";
if($Experimental.IsPresent -and !($Mono.IsPresent)) {
Write-Verbose -Message "Using experimental version of Roslyn."
$UseExperimental = "-experimental"
}

# Is this a dry run?
$UseDryRun = "";
if($WhatIf.IsPresent) {
$UseDryRun = "-dryrun"
}

# Make sure tools folder exists
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
Write-Verbose -Message "Creating tools directory..."
New-Item -Path $TOOLS_DIR -Type directory | out-null
}

# Make sure that packages.config exist.
if (!(Test-Path $PACKAGES_CONFIG)) {
Write-Verbose -Message "Downloading packages.config..."
try { Invoke-WebRequest -Uri http://cakebuild.net/download/bootstrapper/packages -OutFile $PACKAGES_CONFIG } catch {
Throw "Could not download packages.config."
}
}

# Try find NuGet.exe in path if not exists
if (!(Test-Path $NUGET_EXE)) {
Write-Verbose -Message "Trying to find nuget.exe in PATH..."
$existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_) }
$NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1
if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) {
Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)."
$NUGET_EXE = $NUGET_EXE_IN_PATH.FullName
}
}

# Try download NuGet.exe if not exists
if (!(Test-Path $NUGET_EXE)) {
Write-Verbose -Message "Downloading NuGet.exe..."
try {
(New-Object System.Net.WebClient).DownloadFile($NUGET_URL, $NUGET_EXE)
} catch {
Throw "Could not download NuGet.exe."
}
}

# Save nuget.exe path to environment to be available to child processed
$ENV:NUGET_EXE = $NUGET_EXE

# Restore tools from NuGet?
if(-Not $SkipToolPackageRestore.IsPresent)
{
# Restore packages from NuGet.
Push-Location
Set-Location $TOOLS_DIR

Write-Verbose -Message "Restoring tools from NuGet..."
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
Write-Verbose -Message ($NuGetOutput | out-string)

Pop-Location
if ($LASTEXITCODE -ne 0)
{
exit $LASTEXITCODE
}
}

# Make sure that Cake has been installed.
if (!(Test-Path $CAKE_EXE)) {
Throw "Could not find Cake.exe at $CAKE_EXE"
}

# Start Cake
Write-Host "Running build script..."
Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs"
exit $LASTEXITCODE
63 changes: 63 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
###############################################################
# This is the Cake bootstrapper script that is responsible for
# downloading Cake and all specified tools from NuGet.
###############################################################

# Define directories.
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
TOOLS_DIR=$SCRIPT_DIR/tools
NUGET_EXE=$TOOLS_DIR/nuget.exe
CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe

# Define default arguments.
SCRIPT="build.cake"
TARGET="Default"
CONFIGURATION="Release"
VERBOSITY="verbose"
DRYRUN=false
SHOW_VERSION=false

# Parse arguments.
for i in "$@"; do
case $1 in
-s|--script) SCRIPT="$2"; shift ;;
-t|--target) TARGET="$2"; shift ;;
-c|--configuration) CONFIGURATION="$2"; shift ;;
-v|--verbosity) VERBOSITY="$2"; shift ;;
-d|--dryrun) DRYRUN=true ;;
--version) SHOW_VERSION=true ;;
esac
shift
done

# Download NuGet if it does not exist.
if [ ! -f $NUGET_EXE ]; then
echo "Downloading NuGet..."
curl -Lsfo $NUGET_EXE https://www.nuget.org/nuget.exe
if [ $? -ne 0 ]; then
echo "An error occured while downloading nuget.exe."
exit 1
fi
fi

# Restore tools from NuGet.
pushd $TOOLS_DIR >/dev/null
mono $NUGET_EXE install -ExcludeVersion
popd >/dev/null

# Make sure that Cake has been installed.
if [ ! -f $CAKE_EXE ]; then
echo "Could not find Cake.exe."
exit 1
fi

# Start Cake
if $SHOW_VERSION; then
mono $CAKE_EXE -version
elif $DRYRUN; then
mono $CAKE_EXE $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET -dryrun
else
mono $CAKE_EXE $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET
fi
exit $?
8 changes: 8 additions & 0 deletions nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
<add key="DotNet Core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
</packageSources>
</configuration>
1 change: 1 addition & 0 deletions src/DotNetLocalizer.Core/DotNetLocalizer.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<Version>1.0.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
11 changes: 5 additions & 6 deletions src/DotNetLocalizer.Json/DotNetLocalizer.Json.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<Version>1.0.0</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
<ProjectReference Include="..\DotNetLocalizer.Core\DotNetLocalizer.Core.csproj" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DotNetLocalizer.Core\DotNetLocalizer.Core.csproj" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
</ItemGroup>

</Project>
3 changes: 1 addition & 2 deletions src/DotNetLocalizer.Yaml/DotNetLocalizer.Yaml.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<Version>1.0.0</Version>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\DotNetLocalizer.Core\DotNetLocalizer.Core.csproj" />
</ItemGroup>

</Project>
5 changes: 5 additions & 0 deletions tools/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Cake" version="0.13.0" />
<package id="Cake.Powershell" version="0.2.5" />
</packages>
Loading

0 comments on commit 939d7cc

Please sign in to comment.